Michele Simionato <michele.simionato <at> gmail.com> writes: > Finally I did some timing of code like this:: > > from itertools import imap > Point = namedtuple('Point x y'.split()) > > lst = [(i, i*i) for i in range(500)] > > def with_imap(): > for _ in imap(Point, lst): > pass > > def with_star(): > for _ in (Point(*t) for t in lst): > pass > > and as expected the performances are worse with the * notation
BTW, I take back this point. It is true that the generation expression is slower, but the direct equivalent of imap is starmap and using that I don't see a significant difference in execution times. So it seems that starmap is smart enough to avoid unnecessary tuple unpacking (as you probably know ;-). I still don't like for a subclass to have an incompatible signature with the parent class, but that's just me. Michele Simionato _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com