What kind of "thread safe" are deque's actually?

Dennis Lee Bieber wlfraed at ix.netcom.com
Wed Mar 29 13:43:00 EDT 2023


On Wed, 29 Mar 2023 10:50:49 -0400, Jack Dangler <tdldev at gmail.com>
declaimed the following:

>Sorry for any injected confusion here, but that line "data = 
>sorted(data)" appears as though it takes the value of the variable named 
>_data_, sorts it and returns it to the same variable store, so no copy 
>would be created. Am I missing something there?

	The entire Python object/data model.

	Data is not "stored in" variables -- rather names are "attached to"
data.

	sorted() creates a new data object, allocating memory for it. THEN the
name "data" is attached to this new data object (and disconnected from the
previous object). If there are no names left connected to the original
object, the garbage collector reaps its memory.


More information about the Python-list mailing list