Skip to content

interpreters module in python which is backported from the future

License

Notifications You must be signed in to change notification settings

aisk/backports.interpreters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

backports.interpreters

Python package

The interpreters module described in PEP554, which is not implemented now. This is backported from the future.

Install

$ pip install backports.interpreters

Example

from backports import interpreters
import threading


def task():
    intp = interpreters.create()
    intp.run("""
a = 0
for i in range(99999999):
    a += i
print(a)
    """)


ts = []
for _ in range(8):
    t = threading.Thread(target=task)
    t.start()
    ts.append(t)

for t in ts:
    t.join()

Run this code with Python3.12, you will see Python will use 8 cores of CPU:

Python eats 8 CPU cores

Limitations

Only support python3.8+.


「すべてはシュタインズ・ゲートの選択である」

About

interpreters module in python which is backported from the future

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages