DEV Community

Discussion on: Consume 50% less memory with your Python objects

Collapse
 
jeromek13 profile image
Jérôme Krell • Edited

Hey
There is also a performance gain when accessing / initializing the Object, see example. Hope that answers your question

import timeit
print(timeit.timeit("p3 = SmallObject('Jerome', 'K')", "from __main__ import SmallObject")) 
# Output: 0.13634319999982836
print(timeit.timeit("p3 = BiggerObject('Jerome', 'K')", "from __main__ import BiggerObject")) 
# Output: 0.166356599998835
Enter fullscreen mode Exit fullscreen mode