Skip to content

XingerTang/Multithreads-CPython-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multithreads-CPython-Example

An example of lifting the GIL lock with a C extension to allow an efficiency burst with multi-threaded programming in earlier versions of Python 3 (<3.14).

AI Attribution > Code were generated and refined with the assistance of Gemini, an AI model by Google.

Usage instruction

You can build and test with single line:

make test

Or you can also do it step by step:

Remove old build artifacts:

rm -rf build/ dist/ *.egg-info *.so *.pyd

Install C extension in "editable" mode:

pip install -e .

Run the Python code:

python benchmark.py

What to expect in the output:

Starting single-threaded task (100000000 points)...
Single-thread result: 3.14144 in 2.1005s

Starting 4-threaded task (100000000 total points)...
Multi-thread result: 3.14145 in 0.5651s

Speedup: 3.72x
Efficiency: 92.9%

About

An example of lifting the GIL lock with a C extension to allow an efficiency burst with multi-threaded programming in earlier versions of Python 3 (<3.14).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors