15.12.17 02:33, Antoine Pitrou пише:
On Thu, 14 Dec 2017 16:03:48 -0800
Guido van Rossum <gu...@python.org> wrote:
A slot is pretty expensive, as *every* class in existence will be another 8
bytes larger (and possibly more due to malloc rounding).

I'm always surprised by the discussions about class object size.
Even imagining you have 10000 classes in memory (a pretty large number,
though I'm sure you can reach that number with a lot of dependencies),
we're talking about a total 800 kB memory growth (let's recall that
each of those classes will probably have code objects, docstrings and what
not attached to it -- i.e. you don't often create empty classes).

Is it really an important concern?

The increased memory consumption is not the only cost. Initializing new slots takes a time. You have to spent a time for all class objects, not only for theses that have correspondent methods. In case of complex hierarchy the cost is larger, because you need to look up methods in all parent classes. This increases the startup time and increases the cost of creating local classes.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to