Changes between Version 1 and Version 2 of Ticket #24741, comment 24


Ignore:
Timestamp:
03/01/19 13:16:05 (12 months ago)
Author:
embray
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24741, comment 24

    v1 v2  
    1919You can also see in the [https://github.com/python/cpython/blob/69b4a17f342146d6b7a73975a37678db9916aa75/Objects/listobject.c#L799 list.extend] implementation that it has a more optimized code path for the case where it's given a list or tuple and can use the `PySequence_Fast` API, as opposed to the more generic path of having to guess what the new size of the list will be (using `__length_hint__` if there is one) and slowly iterate over the iterable.
    2020
    21 Of course that's all implementation detail and there's no guarantee in the language that this should be faster.  By rights the iterator expression should be "better" but in practice it isn't, at least for small lists.
     21Of course that's all implementation detail and there's no guarantee in the language that this should be faster.  By rights the generator expression should be "better" but in practice it isn't, at least for small lists.