AlanCristhian / statically

Compiles a python function with cython using only a decorator.
MIT License
185 stars 6 forks source link

README: add info that it works with IPython #3

Closed disconnect3d closed 6 years ago

disconnect3d commented 6 years ago

Hey,

The project works fine with IPython, so lets inform people that it do so ;).

Proof below.

Standard Python shell

$ python
Python 3.6.2 (default, Jul 20 2017, 03:52:27) 
[GCC 7.1.1 20170630] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cython, statically
>>> @statically.typed
... def sum_powers(x: cython.int, n: cython.int = 0):
...     return sum([x**n for n in range(1, x + 1)])
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/home/dc/.virtualenvs/cytho/lib/python3.6/site-packages/statically.py", line 65, in typed
    source = _get_source_code(obj)
  File "/home/dc/.virtualenvs/cytho/lib/python3.6/site-packages/statically.py", line 22, in _get_source_code
    lines = inspect.getsourcelines(obj)[0]
  File "/usr/lib64/python3.6/inspect.py", line 952, in getsourcelines
    lines, lnum = findsource(object)
  File "/usr/lib64/python3.6/inspect.py", line 783, in findsource
    raise OSError('could not get source code')
OSError: could not get source code
>>> 

IPython

$ ipython3
/usr/lib/python3.6/site-packages/IPython/core/interactiveshell.py:724: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
  warn("Attempting to work in a virtualenv. If you encounter problems, please "
-~= IPython interactive shell =~-
Defined pretty print function (pp) and libc (CDLL)

In [1]: import statically, cython

In [2]: >>> @statically.typed
   ...: ... def sum_powers(x: cython.int, n: cython.int = 0):
   ...: ...     return sum([x**n for n in range(1, x + 1)])
   ...: 

In [3]: sum_powers(5)
Out[3]: 3905
disconnect3d commented 6 years ago

Closed due to https://github.com/AlanCristhian/statically/pull/4