Commit 4e07f391 authored by Tom Niget's avatar Tom Niget

Add numpy to ext example

parent 9104072b
import pyext import pyext
print("Imported:", pyext.add(5, 3), pyext.fibo(10)) print("Imported:", pyext.add(5, 3), pyext.fibo(10), pyext.squares())
\ No newline at end of file \ No newline at end of file
# coding: utf-8 # coding: utf-8
# extension # extension
def add(x, y): import numpy as np
def add(x, y) -> int:
return x + y return x + y
def fibo(n): def fibo(n):
...@@ -10,5 +12,8 @@ def fibo(n): ...@@ -10,5 +12,8 @@ def fibo(n):
res.append(res[i - 1] + res[i - 2]) res.append(res[i - 1] + res[i - 2])
return res return res
def squares() -> list[int]:
return np.square([x for x in range(5)])
if __name__ == "__main__": if __name__ == "__main__":
print("Python:", add(5, 3), fibo(10)) print("Python:", add(5, 3), fibo(10), squares())
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment