New Types

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • card
    New Member
    • Jun 2007
    • 10

    New Types

    Hey Everyone,

    I have a question about new types in Python. *Just finished reading up and
    trying a few things out, but I'm a little confused about one thing. *When
    declaring a new type, we basically have two new structures. *One is the per
    instance structure (your PyObject structure), which is basically an expansion
    of the PyObject structure. *At the beginning of that structure is the macro
    declaration of PyObject_HEAD which contains the reference counter and a
    pointer to the new type which is a structure of _typeobject. *Then for your
    new type (i.e. your _typeobject structure) there is a place holder for the
    size of your per instance PyObject structure along with all the necessary
    function pointers your new type will support. *My question is this: *Where
    and when does the pointer in your per instance PyObject structure get set? *
    How does the interpreter know that your PyObject structure is related to your
    PyTypeObject structure? *Since your PyObject structure naming convention is
    not tied to your PyTypeObject name, how are the two associated? *I see how
    your type is statically instantiated in the initialization, but I don't see
    where your per instance PyObject is related to it? *Is it simply that the two
    structures co-exist in the same module? *It's just one of those nagging questions. Thanks.
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Hi, card.
    Now this question is nagging me.
    I'll look into it and let you know when/if I find the answer.

    Sorry to be of little help at the moment.

    Thanks for you contributions to the Python Forum.

    Comment

    Working...