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 cimporting classes and functions by just defining there names? #3134

Open
Keithcat1 opened this issue Sep 6, 2019 · 0 comments

Comments

@Keithcat1
Copy link

commented Sep 6, 2019

This would make it a lot easier to work with classes and functions that have lots of arguments and properties.
What I'm suggesting would look something like this.
module.pyx
cdef class example:
cdef int a,b
cpdef get_ints(self):
return (self.a, self.b)

module.pxd
cdef class example

othermodule.pyx
from module cimport example
cdef example x=example()
ex.a=20
x.b=40
print(x.get_ints())

This way, the declaration is taken from one file, nothing has to be changed in two places.
What could also work is adding a new decorator, which allows cimporting of whatever it's used on.
For example:
import cython
@cython.export
cdef class example:
int a,b

This would allow cimporting the example class without a .pyx file.

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