[Python-ideas] Adding "Typed" collections/iterators to Python

Nathan Rice nathan.alexander.rice at gmail.com
Mon Dec 19 20:26:34 CET 2011


On Mon, Dec 19, 2011 at 1:01 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Nathan Rice wrote:
>>
>> [[1, 2], [3, 4], [5, 6]] could serve as an alternate
>> example of why you can't directly map child methods with the same
>> names.
>
>
> If you have to change the names, doesn't that negate the ability of "a
> reliable method to make functions operate on both scalar and
> vector values"?

To clarify...

Functions could reliably support both vector and scalar context, by
checking that a type contract exists.

Because of the name clash between parent and elementwise member
methods when dealing with collections of collections (and some other
classes), if the type contract provided "broadcast" versions of child
methods, they would have to be provided with under an alias, perhaps X
-> elementwise_X.  I do not think people should be able to be
oblivious of when they are calling collection and member methods, that
encourages sloppy programming.  I like the broadcast feature because
it makes it easier to write code in a clear left to right narrative
style, and that seems very pythonic to me compared with an
"inside-out" style.



More information about the Python-ideas mailing list