Segfault using Sage function with try...except AlarmInterrupt

[Václav] maturity and available features of Cython are certainly lower.

[Chris Duston] “superset of Python”

Yes, “superset” is a stretch since the Python versions you can use lag what’s current, though Cython does an admirable job of keeping up. You can check their website to see what version of Python is baked into which version of Cython.

The current Cython is 3.0 which is now going on a year since release. It supports Python ‘3.4+’. I’m pretty sure that the ‘+’ is purely about Python’s built-in backward compatibility and means that nothing introduced after 3.4 will run in Cython 3.0. The next Cython release will “only” catch up to Python 3.6. I imagine keeping up is a big job and a moving target if you set your sights too high.

In short, Cython is “equivalent” to the embedded version of Python, understanding that it may be 99.xx% equivalent, but not 100%.

Cython will run native Python.

It’s not a different language, merely an extension of Python that allows data types to be explicitly declared so that some optimization can be done at the C-level. The primary benefit of this optimization is faster execution speed because the overhead involved with allowing flexibility of shifting data types on the fly is eliminated–but only for the data objects that you explicitly bind to a data type. You can just run your native Python code in Cython if you don’t care about the performance enhancement, as long as your code uses instructions in the embedded Python version.

Why would you just run native Python in Cython…?

Cython allows you to compile a binary executable that isn’t easily cracked into, so you can package commercial code and release it into the wild with less worry of reverse engineering, copying, and licensing/property violations.

An example on that theme... (CLICK to unfold)

I’m in the process of deploying a native Python+OpenCV application with Cython because the licensing and copy protection system that I’m using (from Thales) requires a compiled executable to harden and secure the licensing code. [1] Due to the bonus from Cython of increased speed, hopefully it will be worth the investment in effort to learn the few extra instructions and syntax around type declarations.

Type declaration and steps to compile/package/deploy are the only differences that I’ve found so far–but I’m just getting started. The Cython interpreter may deviate from CPython, but that’s the same scenario for PyPy, Jython and others. Ideally, the programmer and user don’t see much difference beyond the benefits that led to using these CPython alternatives in the first place.


  1. The current copy protection is an in-house design and works well but depends on the computer’s hardware signature and can’t float among a group of software installations. ↩︎