This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Sergey
Recipients Ramchandra Apte, Sergey, aleax, ethan.furman, jcea, oscarbenjamin, serhiy.storchaka, terry.reedy
Date 2013-07-14.12:56:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373806571.55.0.461102105081.issue18305@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-07-14 12:56:11Sergeysetrecipients: + Sergey, aleax, terry.reedy, jcea, ethan.furman, Ramchandra Apte, serhiy.storchaka, oscarbenjamin
2013-07-14 12:56:11Sergeysetmessageid: <1373806571.55.0.461102105081.issue18305@psf.upfronthosting.co.za>
2013-07-14 12:56:11Sergeylinkissue18305 messages
2013-07-14 12:56:11Sergeycreate