On Thu, Aug 4, 2016 at 11:33 PM, Alexander Belopolsky <alexander.belopolsky at gmail.com> wrote: > > On Thu, Aug 4, 2016 at 7:12 PM, Larry Hastings <larry at hastings.org> wrote: >> >> C extension functions get the module passed in automatically, but this is >> done internally and from the Python level you can't see it. > > Always something new to learn! This was not so in Python 2.x - self was > passed as NULL to the C module functions. When did this change? In 2.x this is the `self` parameter (actually named "passthrough" in the source) of Py_InitModule4 [1, 2]. You probably use the Py_InitModule or Py_InitModule3 macros, which pass NULL for this parameter: #define Py_InitModule(name, methods) \ Py_InitModule4(name, methods, (char *)NULL, (PyObject *)NULL, \ PYTHON_API_VERSION) #define Py_InitModule3(name, methods, doc) \ Py_InitModule4(name, methods, doc, (PyObject *)NULL, \ PYTHON_API_VERSION) Python 3's PyModule_Create2 [3-5] API makes this a reference to the module. It's currently implemented in PyModule_AddFunctions [6, 7]. [1]: https://docs.python.org/2/c-api/allocation.html#c.Py_InitModule4 [2]: https://hg.python.org/cpython/file/v2.7.12/Python/modsupport.c#l31 [3]: https://docs.python.org/3/c-api/module.html#c.PyModule_Create2 [4]: https://hg.python.org/cpython/file/v3.5.2/Objects/moduleobject.c#l133 [5]: https://hg.python.org/cpython/file/v3.0b1/Objects/moduleobject.c#l63 [6]: https://docs.python.org/3/c-api/module.html#c.PyModule_AddFunctions [7]: https://hg.python.org/cpython/file/v3.5.2/Objects/moduleobject.c#l387
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