diff --git a/pep-0484.txt b/pep-0484.txt index 1f86e186c..70fa7cabd 100644 --- a/pep-0484.txt +++ b/pep-0484.txt @@ -217,8 +217,12 @@ alias:: T = TypeVar('T', int, float, complex) Vector = Iterable[Tuple[T, T]] - def inproduct(v: Vector) -> T: + def inproduct(v: Vector[T]) -> T: return sum(x*y for x, y in v) + def dilate(v: Vector[T], scale: T) -> Vector[T]: + return ((x * scale, y * scale) for x, y in v) + vec = [] # type: Vector[float] + This is equivalent to:: @@ -228,6 +232,9 @@ This is equivalent to:: def inproduct(v: Iterable[Tuple[T, T]]) -> T: return sum(x*y for x, y in v) + def dilate(v: Iterable[Tuple[T, T]], scale: T) -> Iterable[Tuple[T, T]]: + return ((x * scale, y * scale) for x, y in v) + vec = [] # type: Iterable[Tuple[float, float]] Callable