Message400528
Microbenchmarks show some speed up:
Iterating large range:
$ ./python -m timeit -s 'r = range(0, 10**20, 3**35)' 'list(r)'
Before: 2000 loops, best of 5: 199 usec per loop
After: 2000 loops, best of 5: 113 usec per loop
Unpickling:
$ ./python -m timeit -s 'from pickle import dumps, loads; p = dumps([iter(range(i)) for i in range(1000)])' 'loads(p)'
Before: 500 loops, best of 5: 476 usec per loop
After: 500 loops, best of 5: 363 usec per loop
I did not observe any difference in iterating small ranges and pickling.
Smaller size in memory, smaller pickles. |
|
Date |
User |
Action |
Args |
2021-08-29 12:52:49 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, lukasz.langa, Dennis Sweeney |
2021-08-29 12:52:49 | serhiy.storchaka | set | messageid: <1630241569.07.0.951548549318.issue45026@roundup.psfhosted.org> |
2021-08-29 12:52:49 | serhiy.storchaka | link | issue45026 messages |
2021-08-29 12:52:48 | serhiy.storchaka | create | |
|