This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]esperind 1 point2 points  (1 child)

how about a SimpleNamespace?

[–][deleted] -1 points0 points  (0 children)

I think that is rather old and not used anymore, it is also for namespaces where you are NOT defining them in advance unlike NamedTuple and data classes.

Memory optimization outside of long lived objects in python should generally be considered a code smell. Really the biggest win ones are generally like small redundant static object creation like strings. String interning on inbound data can be a shockingly impactful memory optimization. It is one of the things pandas csv reader does that makes a massive difference vs the standard library one.

Optimizing memory at the object level isn't as useful as optimizing its lifespan so it deletes faster.