On Sat, Jun 20, 2020 at 2:39 AM Steele Farnsworth
If range were to support infinite ranges, range.__len__ would have to be changed to either raise an error or return float('inf') in these cases.
That would be a problem that would have to be solved, as would related concepts like what slicing with negative indices would do - what's range(0, ...)[:-10] give? This doesn't mean the idea is dead in the water, but anyone who's proposing it will need to come up with answers to these questions.
I believe __contains__ would also need to have extra checks.
That'd be easy enough. The check "x in r" has to check three things: is x >= r.start, is r < x.stop, and is (x - r.start) % r.step == 0. Having an infinite end point would simply remove the need for the middle check (or have it always be true). Be aware that this idea is meaningful ONLY for the 'stop' parameter. An infinite start or step makes no sense. I don't see the value myself, but in theory it would make sense to have both bounded and infinite ranges be able to be processed the same way. ChrisA