Skip to content

Preserve module name of jitted class - #8659

Merged
sklam merged 2 commits into
numba:mainfrom
neilflood:jitclass-preserve-modulename
Dec 13, 2022
Merged

sklam merged 2 commits into
numba:mainfrom
neilflood:jitclass-preserve-modulename

Conversation

@neilflood

Copy link
Copy Markdown
Contributor

A normal Python class has a __module__ attribute which tells what module it comes from. However, when a class is decorated with @jitclass, this changes to be numba.experimental.jitclass.base, and so the class looks like it has been imported from some other module.

Documentation tools such as the Python help() function, or Sphinx, will omit classes which are not from the module being processed, and so documentation for @jitclass classes is skipped.

The proposed change carries the module name over from the Python class to the @jitclass version, and thus allows such documentation tools to include them. This will also be consistent with functions decorated with @jit, as they keep their module name unchanged.

I ran the full test suite with this change, using pre-built binaries (0.56.3) from conda, and it does not seem to affect anything. I was unable to set up a full test environment using conda (apparently because of glibc version conflicts??), so could not test with the current HEAD, but am hopeful that nothing else will be affected.

It was not clear if this change would be worth an explicit test, but happy to try and think of something if reviewers think it important to do so.

@esc

esc commented Dec 9, 2022

Copy link
Copy Markdown
Member

@neilflood thank you for the pull-request. I have labelled it as "Ready for Review" and it will hopefully bes assigned a reviewer at the dev meeting next Tuesday. As a heads up, the Numba team is very busy with end of year tasks so it is unlikely that this will receive any more attention before mid January 2023. Thank you in advance for your patience!

PS: I can note at this stage however, that adding an explicit test will most definitely be required and is not optional.

@neilflood

Copy link
Copy Markdown
Contributor Author

@esc Thanks for that. Very good, I will work out a suitable test and add to test_jitclasses.py. :-)

@esc esc added the jitclass label Dec 13, 2022
@sklam sklam self-assigned this Dec 13, 2022

@sklam sklam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sklam sklam added 5 - Ready to merge Review and testing done, is ready to merge and removed 3 - Ready for Review labels Dec 13, 2022
@sklam sklam added this to the Numba 0.57 RC milestone Dec 13, 2022
@sklam

sklam commented Dec 13, 2022

Copy link
Copy Markdown
Member

Congrats on getting your first contribution to Numba!

@neilflood

Copy link
Copy Markdown
Contributor Author

Thank you! :-)

@sklam
sklam merged commit 7e92e22 into numba:main Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Review and testing done, is ready to merge jitclass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants