[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] [PEP 576/580] Reserve one type slot for Cython

As repeatedly said, PEP 580 is very complicated protocol
when just implementing callable object.
It is optimized for implementing custom method object, although
almost only Cython want the custom method type.

I'm not sure adding such complicated protocol almost only for Cython.
If CyFunction can be implemented behind PEP 576, it may be better.

On the other hand, most complexity of PEP 580 is not newly added.
Most of them are in PyCFunction, method_descriptor, and some
calling APIs already.
PEP 580 just restructure them completely to be reusable from Cython.

So I agree that PEP 580 is better when thinking from Cython's side.


I'm not sure which way we should go yet.  But my current idea is:

* Implement PEP 580 as semi-public APIs only for tools like Cython.

  * Other Python implementation may not support it in foreseeable future.
    So such tools should support legacy implementation too.

* PEP 576 and 580 are not strictly mutually exclusive; PEP 576 may be
  accepted in addition to PEP 580, for simpler FASTCALL-able object support.
  Especially for extension author prefer C to Cython (including stdlib).

  * If this happened, PEP 580 can remove one abstraction; tp_ccalloffset is
    offset of PyCCallRoot instead of pointer to it.
    Py_TPFLAGS_FUNCTION_DESCRIPTOR will be removed from PEP 576 too.

INADA Naoki  <songofacandy at gmail.com>