On Wed, Jun 27, 2018 at 12:36:12AM -0700, Michael Selik wrote:
> On Tue, Jun 26, 2018, 11:43 PM Jacco van Dorp <j.van.d...@deonet.nl> wrote:

> > Generators dont have a __len__ method. And they might have min/max
> > that can be calculated without iterating over the entire thing. The
> > builtin range() is an example. (but also an exception, since it does
> > have a __len__ attribute. This is specifically part of range and not
> > generators in general, though.).

range is not a generator.


> > However, range() is an example where the dunders could be valuable -
> > max(range(1e7)) already takes noticable time here, while it's rather
> > easy to figure it out from start stop and step, just like len now does
> > for it.
> >
> 
> Have you ever written ``max(range(x))`` in production code?

I have never written that.

But I have written ``max(iterable)`` dozens of times, where iterable 
could be a range object.



-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to