A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-June/045302.html below:

[Python-Dev] creating factory methods in C extension modules.

[Python-Dev] creating factory methods in C extension modules. [Python-Dev] creating factory methods in C extension modules.Raymond Hettinger python at rcn.com
Tue Jun 8 09:04:59 EDT 2004
> I'm creating an C extension module that returns one of my C-defined
python
> classes from a factory function. is it correct to simple have the
factory
> function allocate and init the object by calling the functions I
defined
> and
> set as tp_new and tp_init in the PyTypeObject? If not am I supposed to
use
> PyObject_New and PyObject_Init or something?

These kind of questions should be directed to comp.lang.python.

FWIW, good examples can be found in Objects/listobject.c.  The code for
list_slice is effectively a factory function that returns a new list.
It calls PyList_New() which calls PyObject_GC_New() to create the new
object.


Raymond


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4