15.12.17 02:33, Antoine Pitrou пише: > On Thu, 14 Dec 2017 16:03:48 -0800 > Guido van Rossum <guido at 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4