aisk / backports.interpreters

interpreters module in python which is backported from the future

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:GNU Lesser General Public License v3.0


Languages

Language:Python 100.0%