Re:Python Practices for Efficient Code: Performance, Memory,...
by dr_zoidberg on Monday August 21, 2017 @12:49PM
(#15065836)
It walks the iterables (no need to convert them to lists), but its main trick is actually knowing how much memory it'll need for the end result, so no re-allocations happen, simply a one pass (through multiple iterables) copy.
[ Parent
| on HN ]
Re:Python Practices for Efficient Code: Performance, Memory,...
by dom0 on Monday August 21, 2017 @04:54PM
(#15067789)
No, it really converts all iterables to lists (there is a utility function in the C API to do just that, because it's kinda hairy to do by hand. PySequence_ToList or so). Otherwise it would not be possible to calculate how much space is required beforehand, since iterables cannot be walked twice.