Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #16442 > unrolled thread

tp_new, tp_alloc, tp_init

Started byMichael Hennebry <egg1nog@gmail.com>
First post2011-11-30 09:10 -0800
Last post2011-12-09 10:33 +1300
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  tp_new, tp_alloc, tp_init Michael Hennebry <egg1nog@gmail.com> - 2011-11-30 09:10 -0800
    Re: tp_new, tp_alloc, tp_init Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-12-09 10:33 +1300

#16442 — tp_new, tp_alloc, tp_init

FromMichael Hennebry <egg1nog@gmail.com>
Date2011-11-30 09:10 -0800
Subjecttp_new, tp_alloc, tp_init
Message-ID<f0bb1447-07b2-4f78-a1af-c702ff2ca31a@da3g2000vbb.googlegroups.com>
I've been reading about writing extension types in C and am rather
fuzzy about the relationship between tp_new, tp_alloc and tp_init.
Most especially, why tp_new? It seems to me that tp_alloc and tp_init
would be sufficient.

Most of my reading has been in the Noddy and Shoddy portions of
docs.python.,org .

[toc] | [next] | [standalone]


#16879

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2011-12-09 10:33 +1300
Message-ID<9kcoopFv41U1@mid.individual.net>
In reply to#16442
Michael Hennebry wrote:
> I've been reading about writing extension types in C and am rather
> fuzzy about the relationship between tp_new, tp_alloc and tp_init.
> Most especially, why tp_new? It seems to me that tp_alloc and tp_init
> would be sufficient.

tp_new and tp_init correspond to the Python methods
__new__ and __init__, and they're separated for the
same reasons they are in Python.

tp_alloc is separate because it allows a type to
use a custom memory allocator without disturbing the
rest of the initialisation mechanism.

-- 
Greg

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web