Closed disconnect3d closed 6 years ago
Hey,
Thanks for such great project :).
This PR improves it a bit so that standard Python REPL works fine.
I have also extended README and included that statically works fine with IPython shell.
(cytho) [dc@dc:statically|support-repl %]$ cat test.py import cython import statically @statically.typed def func(): # Cython types are evaluated as for cdef declarations x: cython.int # cdef int x y: cython.double = 0.57721 # cdef double y = 0.57721 z: cython.float = 0.57721 # cdef float z = 0.57721 # Python types shadow Cython types for compatibility reasons a: float = 0.54321 # cdef double a = 0.54321 b: int = 5 # cdef object b = 5 c: long = 6 # cdef object c = 6 return y+z + a+b+c @statically.typed class A: a: cython.int b: cython.int def __init__(self, b=0): self.a = 3 self.b = b print('func = ', func()) a = A() print(a.a, a.b) (cytho) [dc@dc:statically|support-repl %]$ python -c "import test" /home/dc/Projects/statically/statically.py:100: RuntimeWarning: Current code isn't launched from a file so statically.typed isn't able to cythonize stuff.Falling back to normal Python code. RuntimeWarning func = 12.69763 3 0 (cytho) [dc@dc:statically|support-repl %]$ echo "import test" > a.py (cytho) [dc@dc:statically|support-repl %]$ python a.py func = 12.69763 3 0 (cytho) [dc@dc:statically|support-repl %]$ ipython -c "import test" func = 12.69763 3 0 (cytho) [dc@dc:statically|support-repl %]$ ipython a.py func = 12.69763 3 0 (cytho) [dc@dc:statically|support-repl %]$
Thanks for your contribution. I will explore a way to test it.
Done :)
Hey,
Thanks for such great project :).
This PR improves it a bit so that standard Python REPL works fine.
I have also extended README and included that statically works fine with IPython shell.
Side notes