Hi,
Am 28. Juni 2021 14:10:03 MESZ schrieb Serhiy Yevtushenko:
>could someone clarify, whether there is a proper way to import numpy
>data
>types in pure python mode?
>
>I'm trying to speed up some python code, and would like to keep it, if
>possible, in py file instead of .pyx in order to be able to use
>linters,
>doc and type checkers on python code.
>
>I have found information, how one could use cython annotations for
>declaring types of local variables. However, my code is using as well
>numpy
>np.float64_t, np.uint_64 and np.ndarray variables. When one uses pyx
>file,
>they are getting imported using cimport numpy as np. But I was not able
>to
>find a proper way to import this type in pure python mode.
>
>Could you please clarify, whether such functionality is present in
>cython
>and what is the proper way of using it in pure python mode?
Thanks for bringing this up. I think we should make the numpy module available as cython.cimports.numpy in Python code.
This should already work for compiled code (in Cython 3), but that change would allow the code to work also in Python, to a certain extent.
I didn't do so initially because it takes a while to import NumPy, and that shouldn't happen whenever importing the special cython module from Python. We should look into ways to keep the import lazy. Maybe with an import hook.
--
---
You received this message because you are subscribed to a topic in the Google Groups "cython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cython-users/KXZti9XtR_w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cython-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cython-users/49d7c5d3-e987-473d-bd24-f9d3a4c941abn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cython-users/CAOz1F_v88zHrMh5sN627bLtZD08%3DC9%2BUa9%2BiuaD56PU0mTLEEQ%40mail.gmail.com.