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

[refactor] Cleanup python imports #2231

Merged
merged 1 commit into from
Mar 23, 2021
Merged

[refactor] Cleanup python imports #2231

merged 1 commit into from
Mar 23, 2021

Conversation

k-ye
Copy link
Member

@k-ye k-ye commented Mar 23, 2021

@k-ye k-ye requested a review from taichi-gardener March 23, 2021 10:51
python/taichi/lang/util.py Show resolved Hide resolved
python/taichi/lang/kernel_impl.py Show resolved Hide resolved
python/taichi/core/primitive_types.py Show resolved Hide resolved
@@ -2,6 +2,7 @@
from taichi.core.settings import *
from taichi.core.record import *
from taichi.core.logging import *
from taichi.core.primitive_types import *
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how I feel about this... It's bad to do wildcard import. On the other hand, there are arguments saying that doing this in __init__.py is an exception, in order to lift the symbols into the package level. If not written this way, we would have to write from taichi.x import float32, f32, float64, f64, ..., u64 twice, which is quite repetitive (and equally hard to maintain). What's your opinion :) ?

Copy link
Member

Choose a reason for hiding this comment

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

I think the current solution should be good, given taichi.core.primitive_types already clearly defined the __all__ variable, listing the names to export :-)

python/taichi/lang/__init__.py Show resolved Hide resolved
python/taichi/lang/impl.py Show resolved Hide resolved
python/taichi/lang/matrix.py Show resolved Hide resolved
@k-ye k-ye requested a review from yuanming-hu March 23, 2021 11:46
Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

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

Awesome! LGTM. It's so nice to see the imports are now much more organized than the previous version!

@@ -2,6 +2,7 @@
from taichi.core.settings import *
from taichi.core.record import *
from taichi.core.logging import *
from taichi.core.primitive_types import *
Copy link
Member

Choose a reason for hiding this comment

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

I think the current solution should be good, given taichi.core.primitive_types already clearly defined the __all__ variable, listing the names to export :-)

@k-ye k-ye merged commit 01c2c9c into taichi-dev:master Mar 23, 2021
@k-ye k-ye deleted the fix-py branch March 23, 2021 12:48
@xumingkuan xumingkuan mentioned this pull request Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants