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

Add explicit support for defining namespaces? #3068

Keithcat1 opened this issue Aug 3, 2019 · 3 comments


Copy link

commented Aug 3, 2019

Being able to define your own namespaces would make it easier to organize large Cython modules.
It might look something like this.
"""Constants and functions required by this module"""
cdef int value=1
cdef int another_value=4
cdef add(x=val, y=another_val):
return x+y
print(constants.add(20, constants.val))

This would be like a normal module, except everything defined inside can be used with an attribute lookup and all functions and classes ETC would remember the namespace where they were stored.
This would allow you to define sections that have an obvious purpose and split modules up into different parts.
It would also allow you to put multiple modules into a single Cython file and still allow them to use Cython.


This comment has been minimized.

Copy link

commented Aug 3, 2019

Cython, like Python, uses modules for its namespaces.


This comment has been minimized.

Copy link

commented Aug 3, 2019

That wouldn't work. What I'm suggesting is to add a syntax which allows you to define a new global namespace which is tied to a variable.
Then anything you define in that namespace will be local to that namespace, the same way modules work.


This comment has been minimized.

Copy link

commented Aug 14, 2019

Cython, like Python, uses packages, modules and classes for namespacing. An extension type or struct seems like a reasonable solution to the problem you propose.

@scoder scoder closed this Aug 14, 2019

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