[Python-ideas] Consider making enumerate a sequence if its argument is a sequence

Andrew Barnert abarnert at yahoo.com
Thu Oct 1 08:07:47 CEST 2015


On Sep 30, 2015, at 21:13, Random832 <random832 at fastmail.com> wrote:
> 
> Andrew Barnert via Python-ideas
> <python-ideas at python.org> writes:
>> I think the docs used to use the word "virtual" as a more specific
>> term than "lazy": a view onto an object that conceptually exists but
>> doesn't actually exist is "virtual" (like range, which is a view into
>> the infinite set of integers), but a view into a real object isn't
>> (like dict_keys, which has a reference to an actual dict), nor is
>> something that isn't conceptually view-like at all (like a RNG
>> iterator), even though they're all "lazy".
> 
> If either "lazy" or "virtual" means that the contained objects don't
> exist as python objects until they are accessed, doesn't this extend to
> strings and arrays (and byte strings, byte arrays, and memory views)?

There's a sense in which that's true, and in some discussions (e.g., intimately involving the GC or object sharing or optimization of array algorithms) that would be the most relevant sense, but there's also a sense in which they concretely hold all the values in memory, and in most discussions (e.g., talking about generic sequence algorithms) that would be more relevant. I don't think there's a major problem here—we don't need to eliminate all ambiguity from our speech, only the ambiguity that actually gets in the way.


More information about the Python-ideas mailing list