Cython features and practices

17 views
Skip to first unread message

Aliaksandr Nekrashevich

unread,
Aug 4, 2026, 2:34:43 PM (8 days ago) Aug 4
to cython-users
Hi, Cython group! I hope all is well with you and your families.

Became rather interested in Cython recently and wonder about relevant opportunities. I would appreciate it if somebody could help to answer at least on the part of the following questions:

1. For the "cdef cppclass" definition, may I ask if there is a way to define such a cppclass in the PXD file and implement methods in the PYX? Without any code in extern C++. When I tried this path, code can be included with "include file.pxi", but there is a constructor-level error when defining PXD and PYX for the cimport mechanism.
2. Has anybody managed to get working inheritance with "cdef cppclass" without an external C++ implementation? Frankly, I could not find a way to specify virtual functions and access permissions (public, protected, private). I.e., when managing through shared_ptr, base class methods are unavailable in derived classes. 
3. Looks like the project is rather respectable and mature. Could somebody point to a code style guide for writing in Cython? Best practices? 
4. For the track with cygdb, has somebody managed to turn this approach on with a virtual environment? If so, where can one find precise instructions? I tried to follow the main Cython tutorial, but there, the assumption is that things work out of the box, which has not happened in my case. 

Thank you,
Alexander

P.S. Regardless of the questions, great idea and great project. Accelerates indeed significantly.

da-woods

unread,
Aug 4, 2026, 4:29:57 PM (8 days ago) Aug 4
to cython...@googlegroups.com

Cython-defined (i.e. not extern) "cdef cppclass" was probably a mistake to add to Cython. It's largely undocumented because it's pretty incomplete. And C++ is a complex language and it was never going to be possible to express all of it in Cython.

1. I don't think cdef cppclass works in a pxd file (at least not when used from other files) because no method for sharing the function implementations exists.

2. I believe inheritance works. All functions are virtual so there's no need to specify it. There's no way of specifying access permissions. I'm not aware of any issues with shared_ptr but that doesn't mean there aren't any.

3. I don't know of a specific code-style guide.

4. cygdb doesn't work particularly well (or possibly at all). I've tried to make some improvements to it lately, but you should probably just treat it as broken.

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cython-users/3b0e972f-dd09-4904-898f-10d417a5aa2dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages