Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8604 > unrolled thread
| Started by | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| First post | 2011-06-30 15:10 +0200 |
| Last post | 2011-06-30 15:10 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: keeping local state in an C extension module Stefan Behnel <stefan_ml@behnel.de> - 2011-06-30 15:10 +0200
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Date | 2011-06-30 15:10 +0200 |
| Subject | Re: keeping local state in an C extension module |
| Message-ID | <mailman.523.1309439445.1164.python-list@python.org> |
Daniel Franke, 30.06.2011 13:37: > 2011/6/30 Stefan Behnel: >> There's a PEP for Py3 that enables this through a general framework. In >> general, to achieve this, you may want to allocate the module content >> (including types etc.) on the heap rather than statically. >> >> http://www.python.org/dev/peps/pep-3121/ > > Perfect! Unfortunately, it seems not to be available in 2.x, so > unusable for now. For the foreseeable future the project can not > depend on 3.x as many (internal) target systems are "stable", i.e. are > not updated besides security stuff. Yes, it's Py3 only. >> Take a look at PyCapsule, it may (or may not) be enough for your use case. > > Also a perfectly good solution - unfortunately the same comment about > 3.0 applies here. > > >> However, note the comment about Py_InitModule4() in the docs, where it says >> that the 'self' passing feature isn't used very often. You may or may not >> want to (or need to) use it. > > If there are too many hoops to jump through to get a reasonable > solution working for 2.[567], I might as well go back to > Py_InitModule() and static variables. It's somewhat ugly, but it > works. Py2.x has a PyCObject, basically the predecessor to PyCapsule. Writing your own little type is another option. Stefan
Back to top | Article view | comp.lang.python
csiph-web