since my first time to dabble at python, i began to keep an eye on its performance in multi-core enviornment. As everyone knows, python adapt GIL to prevent thread from interrupting the data.
the pros is learning and using thread become easy and error-less, the downside is you are unable to take any benefit from using multi-core/cpu. A few years ago, i thought probably the next generation of python (next generation of python refers to python 3000 in context) may remove this bar. However, it is not true.
There are few ways of bypassing the GIL and taking benefit from multi-core, after years study and search, i conclude some ways which are listed as follow:
1. use OS-related API to write your code where you need multi-thread, and wrap it as module. the downside is the development speed is slowly and error-prone. using os api let cross-platform become more difficult.
2. use multi-process instead of multi-thread. If you live in Linux, you will be fine with this choice. The python provide os.fork for multi-process usage, furthmore, you may also use a package called pyprocessing. The usage is similar with threading package. The author claims that the package can be used in both of *nix and win32. However, after a few days of use in win32, i found out that it probably was not a feasible choice. The restrictions of pyprocess in win32 are more tense than Linux, the argument, shared object, or data put in a Queue should be pickable (io serialization), that imply some un-plain objects like com-object, proxy-object can not be passed or communicate interprocess. It quickly become a harassment. I personally don't recommend use this package in production development.
3. it is said that use twisted and prospective broker can take benefit from multi-core, however, i havent' gave it a try. I found someone reported that the use of multi-core in twisted is boloney.
If your app is related to server, it is not a bad choice
4. the final choice is to use jython or ironPython instead, these versions of python are based on VM/CLR which supports multi-thread naturally.
分享到:
相关推荐
Multi-core processors are considered now the only feasible alternative to the large single-core processors which have become limited by technological aspects such as power consumption and heat ...
learning, multi-task active learning, multi-task reinforcement learning, multi-task online learning and multi-task multi-view learning. For each setting, representative MTL models are presented. In ...
Assuming you have some iterable of transactions (which are themselves iterables of items) called `transactions` and an integer minimum support value `minsup`, you can find the frequent itemsets in ...
- **Multi-Platform Support**: Both Python and Java are highly portable and can run on multiple platforms. - **Verbosity**: Python is less verbose, using indentation-based syntax instead of explicit ...
2. 赋值表达式(walrus operator):`:=`运算符在Python 3.8引入,但在3.7中可以预见其引入,用于简化某些情况下的赋值和条件检查,如`if (x := some_function()) is not None:`。 3. 字符串格式化:除了传统的`%`...
Recognizing arbitrary multi-character text in unconstrained natural photographs is a hard problem. In this paper, we address an equally hard sub-...and in some cases exceeds, that of human operators.
**Python之PyPI官方下载与使用** Python编程语言在软件开发领域广泛应用,其生态系统中一个重要的组成部分就是Python Package Index(PyPI),这是一个用于分发Python软件包的仓库。PyPI允许开发者分享自己的Python...
This book introduces some machine learning approaches about multi-agent learning. There are a number of algorithms that are typically used for system identification, adaptive control, adaptive signal ...
By understanding the principles behind brightness, ratio, and multi-variant sensors, users can select the appropriate instrument for their specific needs and achieve reliable temperature measurements...
标题中的"python安装python-greedy-methods.rar"暗示了这是一个关于在Python环境中安装和使用名为"greedy_methods"的库或模块的教程。描述中的信息简洁,仅提及"python安装python-greedy_methods.rar",这可能是指一...
result = python_daily_med.some_function() ``` 然而,作为测试版本(beta),"0.1.0b68"可能存在一些未解决的问题或限制。在实际使用中,开发者需要密切关注库的更新,确保及时获取修复错误的新版本。同时,由于...
1、代码实现了基于tcp和udp协议发送someip...2、将SOMEIP报头,Payload、someip-sd报头,flag、Service-Entry、Event-Entry、Option都全部独立通过Python编码实现,方面用户自定义自己想要的发送的各种类型的someip报文
before and just want to add Python to your list of languages, Introducing Python will get you started. It’s an unhurried introduction, taking small steps from the basics to more involved and varied ...
这个资源“appium-python-client-0.16”是Appium的一个Python客户端库,用于编写用Python编写的Appium测试脚本。在Python中使用Appium,可以方便地与iOS和Android设备进行交互,进行功能性和UI测试。 Appium Python...
This book is for Data Science practitioners as well as aspirants who have a basic foundational understanding of Machine Learning concepts and some programming experience with Python. A mathematical ...
result = logonlabs_python.some_function() ``` **Python库的功能** 虽然没有具体描述`logonlabs_python`库的功能,但通常Python库会提供特定领域的功能,如数据处理、网络通信、图形界面等。要了解库的具体用法...
《PyPI官网下载的tencentcloud-sdk-python-aa-3.0.453.tar.gz:深入了解腾讯云Python SDK》 PyPI(Python Package Index)是Python开发者们分享和获取软件包的重要平台,其中包含了丰富的Python库和工具。在我们的...
Therefore, MRSim was created primarily to allow users to develop multi-robot applications, which would benefit working with some specific requirements such as multi-hop communication. Moreover, most...
**PyPI 官网下载 | tencentcloud-sdk-python-rkp-3.0.474.tar.gz** 在Python开发中,PyPI(Python Package Index)是官方的第三方Python软件包仓库,开发者可以在这里发布和分享自己的Python库。"tencentcloud-sdk-...
Central Gateway Architecture A new Network Protocol: FlexRay A new Architecture: Backbone ...Dynamic Multi-PDU-to-Frame Mapping Ethernet and SOME/IP Testing and Analyzing Dynamic PDUs Summary