On 2023-03-29, Jack Dangler <tdl...@gmail.com> wrote: > >> data = sorted(data) > > 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?
Yes, you're missing the basics of what an assignment does in Python and how objects work. Python doesn't have such a thing as "a variable st store". The assignment operator binds a name to an object. The 'sorted(data)' expression creates a new object containing a sorted copy of 'data'. The assignment then binds the name "data" to that new object. The old, unsorted object then becomes inaccessable (unless there are other names bound to it, or it's being otherwise used). At some point that old, unsorted object will "go away" completely and cease to exist. -- Grant -- https://mail.python.org/mailman/listinfo/python-list