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 serhiy.storchaka
Recipients Aaron Hall, anthony shaw, methane, ncoghlan, pablogsal, ronaldoussoren, serhiy.storchaka
Date 2019-04-09.05:50:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1554789057.11.0.055027367208.issue36551@roundup.psfhosted.org>
In-reply-to
Content
> I was going to note that the algorithm Anthony has pursued here is the same one we already use for the list constructor and list.extend(), but Inada-san already pointed that out :)

And that optimization looks questionable to me. I tried to reduce an overhead for small lists, but this requires much more complex code and gives mixed results.

I am -1 for this optimization because it affects only one particular case (neither other kinds of comprehensions, nor generator expressions, nor list comprehensions with conditions) and even in this case it is small. It is possible to add a lot of other optimizations for other cases which will sped up them to 50% or 100%, but we do not do this, because every such optimization has a cost. It increases the amount of code which should be maintained and covered by tests, it adds small overhead in common cases to speed up an uncommon case, and increasing the code base can negatively affect surrounding code (just because the CPU cache and registers are used inappropriate and the compiler optimizes less important paths).

In addition, while this change speed up list comprehensions for long list, it slows down them for short lists. Short lists are more common.
History
Date User Action Args
2019-04-09 05:50:57serhiy.storchakasetrecipients: + serhiy.storchaka, ronaldoussoren, ncoghlan, methane, Aaron Hall, pablogsal, anthony shaw
2019-04-09 05:50:57serhiy.storchakasetmessageid: <1554789057.11.0.055027367208.issue36551@roundup.psfhosted.org>
2019-04-09 05:50:57serhiy.storchakalinkissue36551 messages
2019-04-09 05:50:56serhiy.storchakacreate