Oct-11-2022, 03:18 AM
Recently I posted something here, can't remember exactly which thread, in which I started with an empty string and kept adding bits to it.
deanhystad pointed out, because strings are immutable, I would end up with a lot of strings hanging around in memory. Python doesn't overwrite them. I don't know what happens to them or how Python deals with them.
I was thinking of that today. I get a date from Excel, like 2022-05-21 04:33:27 and put it in this function:
That would leave a lot of old st variables hanging around in memory.
Is there anything I can do about that??
deanhystad pointed out, because strings are immutable, I would end up with a lot of strings hanging around in memory. Python doesn't overwrite them. I don't know what happens to them or how Python deals with them.
I was thinking of that today. I get a date from Excel, like 2022-05-21 04:33:27 and put it in this function:
def string2Seconds(date): st = str(date) # need to specify the format of the string dt = datetime.strptime(st, "%Y-%m-%d %H:%M:%S") # convert dt to epoch seconds seconds = dt.timestamp() return secondsMaybe I am looking for all rows in the Excel after 2022-05-21 04:33:27 or before 2022-05-21 04:33:27
That would leave a lot of old st variables hanging around in memory.
Is there anything I can do about that??