Permalink
Browse files

Simple fibonacci example to test a subset of the Python VM.

  • Loading branch information...
Andy Chu
Andy Chu committed Jun 25, 2018
1 parent 68dc292 commit a5d6a19b27b2defd32fb0af97b7c5139f8c6c653
Showing with 31 additions and 0 deletions.
  1. +21 −0 opy/gold/fibonacci.py
  2. +10 −0 opy/test.sh
View
@@ -0,0 +1,21 @@
#!/usr/bin/python
from __future__ import print_function
i = 0
n = 10
a = 0
b = 1
while True:
print(b)
# NOTE: This would generate BUILD_TUPLE and UNPACK_SEQUENCE bytecodes.
#a, b = b, a+b
tmp = a
a = b
b = tmp + b
i += 1
if i == n:
break
View
@@ -229,4 +229,14 @@ gold() {
done
}
#
# Fibonacci test
#
fib-dis() {
local pyc=_tmp/fibonacci.pyc
../bin/opyc compile gold/fibonacci.py $pyc
../bin/opyc dis $pyc
}
"$@"

0 comments on commit a5d6a19

Please sign in to comment.