Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__del__ beside the __dealloc__ #3612

Closed
brightening-eyes opened this issue May 14, 2020 · 1 comment
Closed

__del__ beside the __dealloc__ #3612

brightening-eyes opened this issue May 14, 2020 · 1 comment

Comments

@brightening-eyes
Copy link

python3 uses del for uninitialization of classes, it would be good to have this as well, it can help to uninitialize python variables, while in dealloc we can uninitialize c variables.
this is useful for example when we are using a module that uses ctypes, or is dependent on some python initialization.

@scoder
Copy link
Contributor

scoder commented May 14, 2020

Right, PEP 442 allows this. Cython currently implements it the other way round and calls tp_finalize() from tp_dealloc(), but it would certainly be nice to also support __del__ directly. PR welcome.

How to do it:
The tp_finalize slot in TypeSlots.py needs to become a MethodSlot backed by __del__.
This seems worth a dedicated set of tests, maybe tests/run/pep442_tp_finalize.pyx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants