multiple discontinued ranges

Paul Rubin no.email at nospam.invalid
Wed Nov 10 16:24:32 EST 2010


xoff <igor.idziejczak at gmail.com> writes:
> I am curious, why wouldn't you advise something like this:
> for i in chain(range(3,7) + range(17,23)):

First of all, the outer chain does nothing.  Second, concatenating the
two lists creates a new list, consuming storage and taking time copying
all the elements.  Third, if there are n lists instead of two, I think
the copying time is O(n**2) in the number of lists because there are n-1
separate copy operations and they keep getting larger.



More information about the Python-list mailing list