[Tutor] Memory consumption question
marc.tompkins at gmail.com
Thu Nov 15 20:03:12 CET 2007
I didn't mean that exactly literally - for goodness' sake, this is a
high-level, object-oriented, interpreted language! We're not writing
machine language here.
What I did mean, and will probably still not express as clearly as I'd like,
is that when you create a "classic" class, lots of options remain unresolved
- slots vs. dict comes to mind - and Python needs to reserve extra space
accordingly. About 134 extra bytes, it would appear.
On Nov 15, 2007 9:32 AM, Kent Johnson <kent37 at tds.net> wrote:
> Marc Tompkins wrote:
> > class B is a "new-style' class, meaning that it inherits from a base,
> > pre-existing class (in this case "object", which is as basic and generic
> > as you can get!). class A has to start from nothing, which is why it
> > consumes more memory yet has less functionality.
> I don't think it is really accurate to say that an old-style class
> "starts from nothing". It doesn't have an explicit base class but it
> does have all the old-style class machinery which is built in to Python.
> I don't know why new-style classes are smaller though. My guess is that
> it is because there was an opportunity to streamline the class structure
> based on experience.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor