Message193048
Attached fasttuple.py is a Proof-of-Concept implementation of tuple, that reuses same data storage when possible. Its possible usage looks similar to built-in tuples:
from fasttuple import ft
a = ft([1,2])
b = a + ft([3,4])
c = b + ft([5,6])
d = b + ft([7,8])
d += ft([9])
d = ft([0]) + d + ft([0])
print(a, b, c, d)
An interesting side-effect of this implementation is a faster __add__ operator:
Python 2.7.5:
Adding 100000 of fasttuples
took 0.23242688179 seconds
Adding 100000 of built-in tuples
took 25.2749021053 seconds
Python 3.3.2:
Adding 100000 of fasttuples
took 0.2883174419403076 seconds
Adding 100000 of built-in tuples
took 25.487935066223145 seconds
(see test() function in fasttuple.py)
This is just a proof of concept, it can be improved in different ways. Similar optimization can be applied to lists. |
|
Date |
User |
Action |
Args |
2013-07-14 12:56:11 | Sergey | set | recipients:
+ Sergey, aleax, terry.reedy, jcea, ethan.furman, Ramchandra Apte, serhiy.storchaka, oscarbenjamin |
2013-07-14 12:56:11 | Sergey | set | messageid: <1373806571.55.0.461102105081.issue18305@psf.upfronthosting.co.za> |
2013-07-14 12:56:11 | Sergey | link | issue18305 messages |
2013-07-14 12:56:11 | Sergey | create | |
|