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

Allow generation of include file that contains all common functions used by a set of Cython modules. #3275

Keithcat1 opened this issue Dec 19, 2019 · 1 comment


Copy link

@Keithcat1 Keithcat1 commented Dec 19, 2019

Normally, you write a single Cython extension and compile it and everything works fine.
However, combining multiple extensions into one library works well with a teleporter.
However, each of these extension modules, to my knowledge, share many of the same code fragments and functions, which makes it really hard or impossible to include them all in one file.
What I am suggesting, is to add an additional argument to Cython.Build.cythonize, called include_name.
This tells the Cython compiler that all functions that could be shared and used by multiple modules should be put in this include file.
Then each module imcludes this file.
This would:

  1. Decrease the size, since there are no coppies of functions and the Python headers are only included once.
    2: Make it easier to call these modules
    I'm hoping for an end result that will allow me to include the generated C files of multiple Cython modules in from another module.
    Hopefully this wouldn't require too much work.

This comment has been minimized.

Copy link

@scoder scoder commented Dec 23, 2019

Sounds interesting, but could be more work than it seems. When you say "include", you mean C pre-processor #include statements and shared header files, right? Not a separate Python module with shared code?

Note that it's already quite easy for users to write common shared modules and have other Cython modules cimport from them through .pxd file declarations. This has the additional advantage of actually removing the duplicated code from the modules, both in the user code and in the generated C code and extension modules.

Could you clarify a bit what advantages you see in your proposal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.