Re: [Python-Dev] [Python-ideas] Expose `itertools.count.start` and implement `itertools.count.__eq__` based on it, like `range`.
On 7 June 2014 19:36, Ram Rachum
My need is to have an infinite immutable sequence. I did this for myself by creating a simple `count`-like stateless class, but it would be nice if that behavior was part of `range`.
Handling esoteric use cases like it sounds yours was is *why* user defined classes exist. It does not follow that "I had to write a custom class to solve my problem" should lead to a standard library or builtin changing unless you can make a compelling case for: * the change being a solution to a common problem that a lot of other people also have. "I think it might be nice" and "it would have been useful to me to help solve this weird problem I had that one time" isn't enough. * the change fitting in *conceptually* with the existing language and tools. In this case, "infinite sequence" is a fundamentally incoherent concept in Python - len() certainly won't work, and negative indexing behaviour is hence not defined. By contrast, since iterables and iterators aren't required to support len() the way sequences are, infinite iterable and infinite iterator are both perfectly well defined. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
On Sat, Jun 7, 2014 at 5:50 AM, Nick Coghlan
My need is to have an infinite immutable sequence. I did this for myself by creating a simple `count`-like stateless class, but it would be nice if
On 7 June 2014 19:36, Ram Rachum
wrote: that behavior was part of `range`.
Handling esoteric use cases like it sounds yours was is *why* user defined classes exist. It does not follow that "I had to write a custom class to solve my problem" should lead to a standard library or builtin changing unless you can make a compelling case for:
* the change being a solution to a common problem that a lot of other people also have. "I think it might be nice" and "it would have been useful to me to help solve this weird problem I had that one time" isn't enough. * the change fitting in *conceptually* with the existing language and tools. In this case, "infinite sequence" is a fundamentally incoherent concept in Python - len() certainly won't work, and negative indexing behaviour is hence not defined. By contrast, since iterables and iterators aren't required to support len() the way sequences are, infinite iterable and infinite iterator are both perfectly well defined.
With all due respect, “"infinite sequence" is a fundamentally incoherent concept in Python” is a bit hyperbolic. It would be perfectly reasonable to have them, but they're not defined (yet).
Cheers, Nick.
-- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (2)
-
Neil Girdhar
-
Nick Coghlan