从Swift Import Python

Python for long has established itself as the undisputed leader of data science. But as the size of data continues to increase, Python’s shortcomings are getting noticed. Slow speed, limitations in parallelism, and lack of type safety all act as a roadblock in large scale applications.

长期以来,Python已成为无可争议的数据科学领导者。 但是随着数据量的不断增加,Python的缺点越来越受到关注。 速度慢,并行性受到限制以及缺乏类型安全性,在大规模应用中都是障碍。

Google is clearly putting its bets on Swift as the future of deep learning. No wonder, they’ve heavily invested in Swift for Tensorflow.

Google显然将赌注押在Swift作为深度学习的未来。 难怪,他们为Tensorflow投入了大量的Swift资金。

While Python boasts of a huge collection of libraries and shifting away from it won’t be a cakewalk, but still we can leverage its interoperability with Swift.

尽管Python拥有大量的库,并且逐渐摆脱它并不是小菜一碟,但是我们仍然可以利用它与Swift的互操作性。

Yes, you can run python code from swift by using the PythonKit, a framework based on the Python module from the Swift for TensorFlow project.

是的,您可以使用PythonKit(基于Swift for TensorFlow项目中基于Python模块的框架)从swift运行python代码。

It’s important to note that Python is not available on iOS. But you can build pretty awesome utility apps for macOS and Linux.

请务必注意,Python在iOS上不可用。 但是您可以为macOS和Linux构建非常棒的实用程序应用程序。

PythonKit的优势 (Advantages of PythonKit)

  • Your swift codebase gets direct access to the rich set of Python modules and packages.

    快速的代码库可直接访问丰富的Python模块和软件包。
  • Python developers can easily build macOS apps to run automation scripts and perform numeric computations.

    Python开发人员可以轻松构建macOS应用程序以运行自动化脚本并执行数值计算。
  • Instead of bundling large OpenCV and Tensorflow frameworks in Swift, you can simply install the Python counterparts on your system and use it across all macOS applications that involve PythonKit.

    您无需在Swift中捆绑大型OpenCV和Tensorflow框架,而只需在系统上安装Python副本,并在涉及PythonKit的所有macOS应用程序中使用它即可。

In the next few sections, we’ll see how to setup PythonKit in a SwiftUI macOS application and perform a few interesting tasks.

在接下来的几节中,我们将看到如何在SwiftUI macOS应用程序中设置PythonKit并执行一些有趣的任务。

在macOS应用程序中添加PythonKit (Adding PythonKit in Your macOS Application)

To get started create a new Xcode project with macOS as the target and add the following pac

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值