472,145 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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.
Jun 14 '07 #1
1 935
6,596 Expert 4TB
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.
Jun 15 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by John Dibling | last post: by
5 posts views Thread by Andy Skypeck | last post: by
8 posts views Thread by Shailesh | last post: by
188 posts views Thread by infobahn | last post: by
5 posts views Thread by Zach | last post: by
58 posts views Thread by jacob navia | last post: by
14 posts views Thread by Lane Straatman | last post: by
159 posts views Thread by Bob Timpkinson | last post: by
3 posts views Thread by sophia.agnes | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.