Skip to content

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

Contributors 2

  •  
  •  

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy