https://github.com/aktech/gil_talk
A talk on Global Interpreter Lock in Python
https://github.com/aktech/gil_talk
multithreading python python-gil
Last synced: 17 days ago
JSON representation
A talk on Global Interpreter Lock in Python
- Host: GitHub
- URL: https://github.com/aktech/gil_talk
- Owner: aktech
- Created: 2018-02-12T22:18:05.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-03-03T10:23:01.000Z (3 months ago)
- Last Synced: 2025-03-31T08:51:12.472Z (about 2 months ago)
- Topics: multithreading, python, python-gil
- Language: Python
- Size: 4.02 MB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GIL Talk
[](https://github.com/aktech/gil_talk/actions/workflows/test.yml)
A talk on Global Interpreter lock.
## Contents
### Functions threads API
```bash
$ python python_multithreading/function_threads.py
```### Class based threads API
```bash
$ python python_multithreading/class_threads.py
```### Extension Module
Python C extension module is written in `extension_module.c` to build it on mac, run:
```bash
$ python python_c_extension/setup.py build
```The above will will compile `extension_module.c`, and produce an extension module
in the build directory. Depending on the system, the module file will end up in
a subdirectory `build/lib.system.extension_module.so`.Copy the built `*.so` file in the current directory, for e.g.:
```bash
$ cp -r build/*/* python_c_extension
```The function defined in extensions module is used in `c_ext_gil_test.py`, run it
as following:```bash
$ python python_c_extension/c_extension_gil.py
Single Thread: 2.118302
Two Threads: 1.348021
```### Compile and run C Threads
* compile
```bash
$ g++ cpp_multithreading/c_threads.cpp -o cpp_multithreading/c_threads
```* run
```bash
$ ./cpp_multithreading/c_threads
```### Acknowledgement
Thanks to [Garvit](https://garvit.in/) and [Suhaib](https://suheb.in/), who played a vital role in the
preparation of this presentation.