On Thu, 12 Mar 2020 at 18:42, Andrew Barnert via Python-ideas <[email protected]> wrote: > What if a for loop, instead of nexting the iterator and binding the result to > the loop variable, instead unbound the loop variable, nexted the Iterator, > and bound the result to the loop variable?
I missed that. But I do not understand how this can speed up any loop. I mean, if Python do this, it does an additional operation at every loop cycle, the unbounding. How can it be faster? Furthermore, maybe I can be wrong, but reassigning to a variable another object does not automatically unbound the variable from the previous object? For what I know, Python is a "pass by value", where the value is a pointer, like Java. Indeed any python variable is a PyObject*, a pointer to a PyObject. When you assign a new object to a variable, what are you really doing is change the value of the variable from a pointer to another. So the variable now points to a new memory location, and the old object has no more references other then itself. Am I right? _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/WFSTCYBWUZWZBHWNX7NSSAJ7H5QIDMOL/ Code of Conduct: http://python.org/psf/codeofconduct/
