有没有一种简单的方法可以使用 Common Lisp 中的 Python 库?
在编写 Common Lisp 代码时,我真正怀念的一件事是访问 Python 库,包括标准库和第三方模块。 CLPython 提供了 Python 功能的有限子集,这阻止了大多数库的使用,因此这对我来说并不是很有用。我希望能够从 Common Lisp 调用 Python 代码,以便它在 CPython 或 PyPy 等 Python VM 中运行。
One thing I really miss when writing Common Lisp code is access to Python libraries, both standard library and third party modules. CLPython provides a limited subset of Python functionality which precludes the use of most libraries, so that's not really useful to me. I would like to be able to call Python code from Common Lisp such that it runs in a Python VM like CPython or PyPy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
(编辑)我们现在有 py4cl: https://github.com/bendudson/py4cl
下面是在 Lisp 程序中使用 Numpy 和 Scipy 的示例:
您可能还喜欢 async-process ,它允许将代码发送到正在运行的 Python 进程。它用于 Lem 编辑器。
使用示例:
(edit) We now have py4cl: https://github.com/bendudson/py4cl
Here's its example using Numpy and Scipy from a Lisp program:
You might also like async-process, which allows to send code to a running Python process. It is used in the Lem editor.
Example use:
一种解决方案是 python-on-lisp。它应该可以通过 ASDF 安装。它已经有几年没有维护或更新了,所以可能有更好的东西可用。
One solution is python-on-lisp. It should be ASDF-installable. It hasn't been maintained or updated for a couple years, so there may be something better available.
您可能想尝试 burgled-batteries,它是 Python 和 Lisp 之间的桥梁(FFI 绑定等)。 )。
从描述来看,“burgled-batteries 提供了 Python(特别是 Python 的 CPython 实现)和 Common Lisp 之间的填充程序。”
You may want to try burgled-batteries, a bridge between Python and Lisp (FFI bindings, etc.).
From the description, "
burgled-batteries
provides a shim between Python (specifically, the CPython implementation of Python) and Common Lisp."我建议为您的代码编写一个“暴露器”接口,该接口接受文本并写入文本,以便您可以在命令行上调用它。理想情况下,使用典型的 STDIN |标准输出方法。
我相信这通常是非性能应用程序的最佳方法。
I would suggest writing an "exposer" interface for your code that takes text and writes text such that you can call it on the command line. Ideally, with a typical STDIN | STDOUT approach.
I believe that is typically the best approach for non-performance applications.
我知道这是不同的语言,但为什么不尝试 Clojure 和 Jython :) : )
也许你会发现自己恰好在你想要的地方。
I know this are different languages, but why don't you give Clojure and Jython a try :) :)
Perhaps you find your self exactly where you want.