如何在 Python packages/extensions 中使用 Crystal?
How can I use Crystal in Python packages/extensions?
是否可以在 Python3 packages/extensions 中使用 Crystal?
dl
已在 python3 中弃用,请查看 ctypes
。
这可能是这里突出显示的:https://github.com/hyronx/crystal-shared-lib
这在 python3
中可能是什么样子:
from ctypes import *
cdll.LoadLibrary("libcrystal-shared-lib.so")
crystal = CDLL("libcrystal-shared-lib.so")
crystal.test(None)
注意
我现在不确定基元如何从 Python 的 None
转换为 C 的 None 再到 Crystal 的 Nil
,但是 nil returns a 0_u64
,所以这是某种提示。
- https://docs.python.org/3/library/ctypes.html#fundamental-data-types
- https://github.com/crystal-lang/crystal/blob/391785249f66aaf5929b787b29810aeb4af0e1e8/src/nil.cr#L42
相关帖子:
是否可以在 Python3 packages/extensions 中使用 Crystal?
dl
已在 python3 中弃用,请查看 ctypes
。
这可能是这里突出显示的:https://github.com/hyronx/crystal-shared-lib
这在 python3
中可能是什么样子:
from ctypes import *
cdll.LoadLibrary("libcrystal-shared-lib.so")
crystal = CDLL("libcrystal-shared-lib.so")
crystal.test(None)
注意
我现在不确定基元如何从 Python 的 None
转换为 C 的 None 再到 Crystal 的 Nil
,但是 nil returns a 0_u64
,所以这是某种提示。
- https://docs.python.org/3/library/ctypes.html#fundamental-data-types
- https://github.com/crystal-lang/crystal/blob/391785249f66aaf5929b787b29810aeb4af0e1e8/src/nil.cr#L42
相关帖子: