Message339702
> 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. |
|
Date |
User |
Action |
Args |
2019-04-09 05:50:57 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ronaldoussoren, ncoghlan, methane, Aaron Hall, pablogsal, anthony shaw |
2019-04-09 05:50:57 | serhiy.storchaka | set | messageid: <1554789057.11.0.055027367208.issue36551@roundup.psfhosted.org> |
2019-04-09 05:50:57 | serhiy.storchaka | link | issue36551 messages |
2019-04-09 05:50:56 | serhiy.storchaka | create | |
|