0

Note: I know how to cythonize my own Python modules.

So, I have managed to cythonize some of my Python modules, and I've gained some speed. The question is, since cython:

The goal of cython is to be compatible with python, i.e. that you can cythonize any python code and it will work as before. Currently, a large fraction of python code already works. Cython furthermore allows you to optimize parts of your code and compile it into more efficient C code.

Source: What does Cython do with imports?

Now, the biggest issue in my code evolve around re.py, the built-in Python Regular Expression module, despite the fact, that I am per-compiling my regexes.

  • Most of the work in the builtin `re` module is in a C library anyway, so you'd gain little – DavidW Jul 30 '19 at 15:36
  • Read https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiling-with-pyximport (e.g. `pyimport=True`), but as I say you won't gain much in you your case – DavidW Jul 30 '19 at 15:40
  • @DavidW, what would be a better solution from your experience? Thanks! – Izabella Svensson Jul 30 '19 at 16:20
  • 1) Ask a question targeted at optimizing your regexes - I think how you "phrase" your regex can sometimes have a huge impact on performance (but I'm really not an expert). 2) Look at using different regex libraries - there's certainly a few other options, or you could try to wrap a C/C++ library. 3) Can you use something simpler that regexes (i.e. a simple character search)? – DavidW Jul 30 '19 at 18:38

0 Answers0