[issue36693] Reversing large ranges results in a minor type inconsistency

2019-04-21 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

This all seems proper to me.  In each case, an iterator is returned -- that is 
the documented behavior.  The specific type of iterator is allowed to vary in 
ways that are convenient for the implementation.

Specifically, reversed() will call __reversed__() which must return an iterator 
but its type is allowed to vary.  That is really convenient for handling 
extreme ranges separately from the fast, common case of smaller ranges.

--
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36693] Reversing large ranges results in a minor type inconsistency

2019-04-21 Thread Paul Ganssle


Paul Ganssle  added the comment:

I believe the relevant code is here:

https://github.com/python/cpython/blob/bb86bf4c4eaa30b1f5192dab9f389ce0bb61114d/Objects/rangeobject.c#L1038

It looks like it's a performance enhancement and that for ranges where the 
beginning and end can fit in a C long, a faster iterator that uses C types 
under the hood is returned, and for ranges where the boundaries *can't* be 
represented by a C long, it defaults to the slower `longrange_iterator`, that 
uses Python integers.

It *may* be possible to disguise this from the end user, but I'm not sure if 
doing so is warranted. I have always treated the specific type returned by 
`iter()` to be an implementation detail, other than the fact that it is an 
iterator.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36693] Reversing large ranges results in a minor type inconsistency

2019-04-21 Thread Paul Ganssle


Paul Ganssle  added the comment:

I have edited the title to be a bit more and give more context. Donald, if you 
feel I have misrepresented your issue, please feel free to tweak it further.

--
nosy: +p-ganssle
title: Minor inconsistancy with types. -> Reversing large ranges results in a 
minor type inconsistency

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com