[Python-Dev] PEP 579 and PEP 580: refactoring C functions and methods (original) (raw)
Stefan Behnel stefan_ml at behnel.de
Sat Jul 7 03:32:13 EDT 2018
- Previous message (by thread): [Python-Dev] PEP 579 and PEP 580: refactoring C functions and methods
- Next message (by thread): [Python-Dev] PEP 579 and PEP 580: refactoring C functions and methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
INADA Naoki schrieb am 07.07.2018 um 06:10:
How often "custom method type" are used?
I thought Cython use it by default. But when I read code generated by Cython, I can't find it. It uses normal PyMethodDef and tpmethods. I found CyFunction in Cython repository, but I can't find how to use it. Cython document doesn't explain any information about it.
Its usage is disabled by default because of some of the problems that Jeroen addresses in his PEP(s).
You can enable Cython's own function type by setting the compiler directive "binding=True", e.g. from your setup.py or in a comment at the very top of your source file:
# cython: binding=True
The directive name "binding" stems from the fact that CyFunctions bind as methods when put into classes, but it's really misleading these days because the main advantage is that it makes Cython compiled functions look and behave much more like Python functions, including introspection etc.
Stefan
- Previous message (by thread): [Python-Dev] PEP 579 and PEP 580: refactoring C functions and methods
- Next message (by thread): [Python-Dev] PEP 579 and PEP 580: refactoring C functions and methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]