I have a sqlalchemy query that returns a tuple. I pass this tuple to a function, and since it is an immutable type, a new instance of the tuple is created in the called function.
How does python handle this in terms of memory management? Is the full copy of the tuple created, or does it use some kind of smart "write / null copy"?
The problem for me is that these source tuples can consume large amounts of memory, and just by calling a function to do some processing on them, Python will effectively double the memory consumption.
With the exception of writing inline code, how can I avoid such inefficiencies?
Chris source share