Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cthreading implements Python 2 Lock, RLock, and Condition in C, speeding up threads synchronization and decreasing cpu usage.
Status: |travis|
.. |travis| image:: https://travis-ci.org/nirs/cthreading.svg?branch=master :alt: Travis-CI Build Status :target: https://travis-ci.org/nirs/cthreading
cthreading eliminates the overhead of threading.RLock
and
threading.Condition
which are implemented in pure Python in Python 2.
In particular, threading.Condition
is implemented using polling. In
Python 3 threading.Condition
is implemented without polling;
cthreading implements a similar design in C.
.. code-block::
$ time python whispers.py -m cthreading
real 0m2.664s
user 0m2.965s
sys 0m0.808s
$ time python3 whispers.py
real 0m9.664s
user 0m8.949s
sys 0m1.812s
$ time python whispers.py
real 0m14.914s
user 0m16.986s
sys 0m12.690s
$ time python whispers.py -m pthreading
real 0m20.169s
user 0m23.062s
sys 0m17.022s
Your application is unlikely to have similar workload; do not expect this improvement.
For more info see https://github.com/nirs/cthreading/wiki/performance.
Import cthreading before any other module and monkeypatch the thread and threading modules. From this point, threading.Lock, threading.RLock, and threading.Condition are using cthreading.
.. code-block:: python
import cthreading
cthreading.monkeypatch()
Note: cthreading will raise RuntimeError if the threading module was
imported before cthreading.monkeypatch()
is called.
For rpm based distributions::
yum install python-devel python-test
For deb based distributions::
apt-get install python-dev libpython2.7-testsuite
Installing Python packages::
pip install pytest pytest-timeout yappi==0.93
Building and running the quick tests::
make
Before submitting patches, run the Python regression tests suite::
make regrtest
Check the Makefile
for more info.
pthreading <https://github.com/oVirt/pthreading>
_ - uses
pthread_mutex and pthread_cond apis directly via ctypes. This
introduces undefined behavior and actually slower and increases cpu
usage in most cases compared to the original Python implementation.FAQs
C implementation of Python 2 threading's Lock, RLock, and Condition
We found that cthreading demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.