range

Schachner, Joseph Joseph.Schachner at Teledyne.com
Mon Jun 25 16:09:19 EDT 2018


Re: "I know I'm going to get flak for bringing this up this old issue, but remember when you used to write a for-loop and it involved creating an actual list of N integers from 0 to N-1 in order to iterate through them? Crazy.

But that has long been fixed - or so I thought. When I wrote, today:



    for i in range(100000000): pass      # 100 million



on Python 2, it used up 1.8GB, up to the limit of my RAM, and it took several minutes to regain control of my machine (and it never did finish). You don't expect that in 2018 when executing a simple empty loop.

On Py 2 you have to use xrange for large ranges - that was the fix.

Somebody however must have had to gently and tactfully point out the issue. I'm  afraid I'm not very tactful."



It HAS been fixed in Python 3, since the beginning of that branch.  In Python 3 range is what xrange was in Python 2.  I used past tense there on purpose.



Python 2 actual demise is scheduled.  See: https://python3statement.org/

It's a list of project that have pledged to drop support for Python2.7 no later than January 1, 2020. You will recognize many of them: Pandas, IPython, NumPy, Matplotlib, Jupyter... etc



Anyone talking about the future of Python and features that might be added to Python really has to be talking about Python 3, because Python 2 support is already ramping down and will completely end on January 1, 2020.  The original plan was to end it in 2015, but the extra five years were added to give everyone plenty of time to switch.



-- Joseph S.



More information about the Python-list mailing list