设为首页 收藏本站
查看: 731|回复: 0

[经验分享] (Python编程)“C海迷航”

[复制链接]

尚未签到

发表于 2017-4-22 14:39:22 | 显示全部楼层 |阅读模式
Programming Python, 3rd Edition 翻译
最新版本见:http://wiki.woodpecker.org.cn/moin/PP3eD

22.1. "I Am Lost at C"

22.1. “C海迷航”

So far in this book, we've been using Python as it comes out of the box. We have used interfaces to services outside Python, and we've coded extensions as Python modules. But we haven't added any external services beyond the built-in set. For many users, this makes perfect sense: such standalone programming is one of the main ways people apply Python. As we've seen, Python comes with batteries includedinterfaces to system tools, Internet protocols, GUIs, filesystems, and much more, are already available.

目前为此,我们使用Python一直是拿来就用。我们使用了Python外部服务的接口,我们以Python模块的方式编写了扩展。但我们还没有在内建功能之上添加任何外部服务。对许多用户来说,这已足够:这种单一的编程是人们应用Python的主要方式之一。正如我们所见,Python自带电池,很多接口都已经是可用的,如系统工具,因特网协议,GUI,文件系统等等。

But for many systems, Python's ability to integrate with C-compatible components is a crucial feature of the language. In fact, Python's role as an extension and interface language in larger systems is one of the reasons for its popularity and why it is often called a "scripting" language. Its design supports hybrid systems that mix components written in a variety of programming languages. Because different languages have different strengths, being able to pick and choose on a component-by-component basis is a powerful concept. You can add Python to the mix anywhere you need an easy-to-use and flexible language tool, without sacrificing raw speed where it matters.

但对许多系统来说,Python与C兼容部件的集成能力是一项至关重要的语言特性。实际上,Python可在大型系统中作为扩展和接口语言是其受欢迎的原因之一,也是它常被称为“脚本”语言的原因之一。它的设计支持混合系统,可融合多种编程语言编写的部件。因为不同的语言具有不同的强项,所以能够为不同部件挑选不同语言是一个强大的概念。当你需要一种好用又灵活的语言工具时,你可以加入Python,它不会牺牲速度,而速度是重要的。

For instance, compiled languages such as C and C++ are optimized for speed of execution, but are complex to programfor developers, and especially for end users. Because Python is optimized for speed of development, using Python scripts to control or customize software components written in C or C++ can yield more flexible systems and dramatically faster development modes. Moreover, systems designed to delegate customizations to Python scripts don't need to be shipped with full source code and don't require end users to learn complex or proprietary languages. Moving selected components of a pure Python program to C can also optimize program performance.

例如,编译型语言如C和C++是针对执行速度优化的,但是对开发者来说,特别是最终用户来说,编程复杂。因为Python是针对开发速度优化的,使用Python脚本来控制或定制C或C++写的软件部件,可以产生更灵活的系统,也明显是一种更快速的开发模式。而且,如果系统设计成用Python脚本处理定制内容,就不必附带全部的源代码,也不要求最终用户去学习复杂或私有的语言。有选择地将纯Python程序的部件转化为C也可以优化程序性能。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-367886-1-1.html 上篇帖子: [python]用python实现的pca算法 下篇帖子: 解读Python内存管理机制
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表