If you didn't know, range objects already support most non-mutating list
methods:

    >>> fakelist = range(1, 101)
    >>> fakelist[-1]
    100
    >>> fakelist[-10:]
    range(91, 101)
    >>> 50 in fakelist
    True
    >>> fakelist.index(50)
    49

Range objects are more efficient than lists since they use O(1) memory
instead of O(n), and many of the methods take O(1) time instead of O(n).
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/VTRVLDZU35OZEMWITGZU64B6HNQZGWV4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to