[Tutor] Memory consumption question

Tiger12506 keridee at jayco.net
Fri Nov 16 23:56:35 CET 2007


> OK, the analogy is cute, but I really don't know what it means in
> Python. Can you give an example? What are the parts of an old-style
> class that have to be 'ordered' separately? How do you 'order' them
> concisely with a new-style class?
>
> Thanks,
> Kent

He is setting up the analogy so that python is the waiter (or waitress)
taking the order.
A "Reuben" in this case is a new-style class, whereas the whole list of
sandwich components
is also a reuben but expressed in old style class language. So, basically,
he's saying that new
style classes have more initial components but take up less room than old
style classes because the
waitress has less to write on her notepad.

As for what has to be ordered seperately, he is treating the concept of a
class abstractly as a
sandwich. So he's saying that python has to "write less on the order pad" in
order to create a
new-style class because it's been restructured like that, whereas python
writes all the stuff down,
even for an empty class. Whether that's actually true or not, i do not know.
I personally cannot imagine
that a simple restructuring of classes can make that drastic a change.

Here's the only way I can imagine it - in C++. C++ comes with virtual
methods, i.e. methods of a base
class that can function properly if the child does not provide that method
in its definition. So I presume
that he is thinking along the lines of old-style classes are C-structured
based, whereas new-style classes
are C++ based (even if they're not written in C++) with virtual methods -
where you only need one copy
of the methods in memory for all new-style classes.

Maybe I'm way out in left field. I do not know. That is one explanation that
I have provided myself so that
I feel I have an understanding. Interpret it as you will.

JS



More information about the Tutor mailing list