Quickstart
Install the CLI, sign in, compile a Python program, compare its RAVEN hash with a Rust version, and fix a refusal.
Preview. Atracode opens at launch, and the commands, tools and API shapes on this page may change before then.
This walkthrough compiles a small compound interest program in Python, then the same program in Rust, and shows that both get the same RAVEN hash. It finishes by making the compiler refuse a program and fixing it. It uses a few of the 250 compilations a month on the free Community plan.
Note: Hashes on this page are illustrative. Your output will show the real hash for your program.
Install the CLI
curl -fsSL https://atracode.sh | sh
The script installs the atracode command on your path.
Sign in
atracode login
This opens your browser. Sign in with Google, GitHub, an email link or SAML SSO. If you don’t have an account yet, signing in creates one on the Community plan.
On a server or in CI, set an API key instead of signing in:
export ATRACODE_API_KEY=atc_live_xxxxxxxxxxxx
See Authentication for how keys work.
Compile a Python program
Save this as interest.py. It grows a balance held in cents by a rate in basis points for a number of years, rounding half away from zero each year.
def compound(balance: int, rate_bp: int, years: int) -> int:
# integer cents; round half away from zero, like COBOL ROUNDED
for _ in range(years):
delta = balance * rate_bp
balance += (delta + 5_000) // 10_000
return balance
print(compound(1_000_000, 425, 30))
Compile it:
atracode compile interest.py
verified raven:13803fe6908d64b3301b931688e6244c99d9b80f15c781f5de7581abb7c3d2af
verified means two things happened. The program was lowered to a Semantic Execution Graph, and that graph was run against CPython over a sweep of inputs and matched it bit for bit.
Read the RAVEN hash
The 64 hex characters after raven: are the program’s RAVEN hash, a SHA-256 hash of the graph in canonical form. It describes what the program computes, so renaming variables, reformatting or changing build settings leaves it unchanged.
To print the hash on its own, for a script or a cache key:
atracode hash interest.py
To see what the graph reads and writes, and its bounds:
atracode inspect interest.py
Compile the Rust version
Save the same computation in Rust as interest.rs:
fn compound(mut balance: u64, rate_bp: u64, years: u32) -> u64 {
// integer cents; round half away from zero
for _ in 0..years {
balance += (balance * rate_bp + 5_000) / 10_000;
}
balance
}
fn main() {
println!("{}", compound(1_000_000, 425, 30));
}
atracode compile interest.rs
verified raven:13803fe6908d64b3301b931688e6244c99d9b80f15c781f5de7581abb7c3d2af
The hash is identical. The two files share no syntax, but they compute the same thing, so they lower to the same graph. This time the check ran against rustc.
Check equivalence directly
verify-equivalence compiles both files and compares them in one command:
atracode verify-equivalence interest.py interest.rs
identical raven:13803fe6908d64b3301b931688e6244c99d9b80f15c781f5de7581abb7c3d2af
If the programs differ, the command reports both hashes and an input on which their outputs diverge. Try changing the Rust rounding to (balance * rate_bp) / 10_000 and running it again.
See a refusal and fix it
Add import time at the top of interest.py and change the last line so the number of years depends on the clock:
print(compound(1_000_000, 425, int(time.time()) % 40))
Compile again:
atracode compile interest.py
refused interest.py:10:36 reads time.time(), which differs on every run
hint: pass the timestamp in as an argument and compile again
Atracode can’t check a result that changes every time the program runs, so it stops at the exact call and compiles nothing. To fix it, replace import time with import sys and take the value as an input:
print(compound(1_000_000, 425, int(sys.argv[1])))
atracode compile interest.py
This compiles and verifies. Its hash differs from the earlier one, because the program now takes years as an input instead of fixing it at 30. See Refusals for the other common causes.