[Python-Dev] [Python-ideas] Expose `itertools.count.start` and implement `itertools.count.__eq__` based on it, like `range`.

Neil Girdhar mistersheik at gmail.com
Sat Jun 7 19:57:05 CEST 2014


On Sat, Jun 7, 2014 at 5:50 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> On 7 June 2014 19:36, Ram Rachum <ram.rachum at gmail.com> wrote:
> > 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.
>

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 at gmail.com   |   Brisbane, Australia
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140607/96ff9c87/attachment-0001.html>


More information about the Python-Dev mailing list