How to add rust code in the sub-module of python project? #2909
Unanswered
evan0greenup
asked this question in
Questions
Replies: 1 comment
-
English is not my native so sorry if there is some mistakenormal wayas you can see, pyo3 project have a
And remeber you need to copy your from .some import * # remeber to use releative import
from typing import TYPE_CHECKING
if TYPE_CHECKING:
def this_is_rust(some_int: int) -> str: ... Then you can use your rust code from hello.rust_code import this_is_rust
this_is_rust(1123) from hello import rust_code
rust_code.this_is_rust(1234) tricky wayIf you dont want to copy
from libs import *
from .some import * # remeber to use releative import Then you can add these typing code to any of them from typing import TYPE_CHECKING
if TYPE_CHECKING:
def this_is_rust(some_int: int) -> str: ... Then you can use your code just like normal way |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If I want to add my rust code to the sub-module (not the top level) of my python project, what should I do?
For example I the root module of my python project is
hello
. It contains three sub-modulehello.alice
,hello.bob
,hello.carol
. I want my rust code define the member attribute (fields and functions) of modulehello.alice
. And the other two sub-module is pure-python. What should I do?Beta Was this translation helpful? Give feedback.
All reactions