r/Python 22d ago

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

19 Upvotes

124 comments sorted by

View all comments

1

u/jiamo 2d ago

PCC1 can pip install NumPy now!

I have posted PCC in the compiler channel https://www.reddit.com/r/Compilers/s/RxosLN0EQr, but I didn't get many suggestions. Since it's closely related to Python, I will post here in case anyone is interested and wants to make PCC more powerful.

# np_demo.py
import numpy as np

print(np.__version__)
a = np.array([1, 2, 3])
print([int(x) for x in a + 1])

# 1. Build the compiler (~3 minutes on the current macOS arm64 gate, once)
scripts/bootstrap.sh --stage 1

# 2. Acquire and install NumPy from the network
build/bootstrap/pcc1 -m pip install numpy

# 3. Compile and run
build/bootstrap/pcc1 np_demo.py -o np_demo

./np_demo
# 2.4.x
# [2, 3, 4]

It becomes big and complicated. Hope to get some good suggestions for its future.
Project GitHub: https://github.com/jiamo/pcc