Move IPython's cython extension to cython
As you probably know, IPython has a "cython magic" [1], an extension to interface ipython with cython, allowing to use cython code in the interactive session. Originally, few of these "language specific magics" (R, cython, octave, etc) were included builtin in IPython, but then the IPython core developers decided break out them (with fair arguments IMHO [2]), either to be included in the "language package" they depend on or as a third party extensions. At the moment, cython-magic is the only one language specific extension left to move. The rest were moved to the packages they depend on [3] So, this message is to ask if the Cython project would like to import this code, task that Brian Grangrer (the author of the cython-magic extension and IPython core dev) entrusted me [3]. Of course, I could help you preparing a PR that migrate the module, its tests and documentation, preserving the git history as far as possible. let me know your opinion/decision cheers Martin. [1] http://ipython.org/ipython-doc/dev/config/extensions/cythonmagic.html [2] https://github.com/ipython/ipython/issues/3150 [3] https://github.com/ipython/ipython/issues/3803 [4] https://github.com/ipython/ipython/issues/3150#issuecomment-37203217 -- mgaitan.github.io textosyprextextos.com.ar -- mgaitan.github.io textosyprextextos.com.ar
On Fri, Apr 4, 2014 at 10:55 AM, Martín Gaitán <gaitan@gmail.com> wrote:
As you probably know, IPython has a "cython magic" [1], an extension to interface ipython with cython, allowing to use cython code in the interactive session.
Originally, few of these "language specific magics" (R, cython, octave, etc) were included builtin in IPython, but then the IPython core developers decided break out them (with fair arguments IMHO [2]), either to be included in the "language package" they depend on or as a third party extensions.
At the moment, cython-magic is the only one language specific extension left to move. The rest were moved to the packages they depend on [3]
So, this message is to ask if the Cython project would like to import this code, task that Brian Grangrer (the author of the cython-magic extension and IPython core dev) entrusted me [3].
Of course, I could help you preparing a PR that migrate the module, its tests and documentation, preserving the git history as far as possible.
let me know your opinion/decision
I'd say this could generally make sense. Would it be the case that iff cython is installed then the %cython magic would be available and just work? Also, how testable is this (e.g. via automated tests vs. having to fire up a notebook and test it manually)? - Robert
On Sun, Apr 6, 2014 at 12:37 AM, Robert Bradshaw <robertwb@gmail.com> wrote:
I'd say this could generally make sense. Would it be the case that iff cython is installed then the %cython magic would be available and just work?
Yes, but before to use it, you'll need to load the extension somewhere. Could be with ipython's %load_ext or setting up it in your config script to be loaded automatically on the startup. For example, see how octave magic (included in the package oct2py) works http://nbviewer.ipython.org/github/blink1073/oct2py/blob/master/example/octa... and here is the code https://github.com/blink1073/oct2py/tree/master/oct2py/ipython Also, how testable is this (e.g. via automated tests vs. having
to fire up a notebook and test it manually)?
There is some unittests https://github.com/ipython/ipython/blob/master/IPython/extensions/tests/test... Of course, they could/should be included in the moving. I could refactor them to remove Nose as a requirement, but obviously IPython (probably few versions) would be mandatory to run them. let me know any other consideration/question. cheers Martin -- mgaitan.github.io textosyprextextos.com.ar
Martín Gaitán, 06.04.2014 06:24:
On Sun, Apr 6, 2014 at 12:37 AM, Robert Bradshaw wrote:
I'd say this could generally make sense. Would it be the case that iff cython is installed then the %cython magic would be available and just work?
Yes, but before to use it, you'll need to load the extension somewhere. Could be with ipython's %load_ext or setting up it in your config script to be loaded automatically on the startup.
For example, see how octave magic (included in the package oct2py) works
http://nbviewer.ipython.org/github/blink1073/oct2py/blob/master/example/octa...
and here is the code https://github.com/blink1073/oct2py/tree/master/oct2py/ipython
Would it be ok to expose the "load_ipython_extension()" function directly on the Cython package? Then you'd just say "%load_ext Cython". I suggest to drop the implementation into Cython/Build/IPythonMagic.py and import it from there inside of "load_ipython_extension()". There is a "Tests" package in there as well. It's also likely that the implementation could benefit from a refactoring within that package to avoid code duplication.
Also, how testable is this (e.g. via automated tests vs. having to fire up a notebook and test it manually)?
There is some unittests
https://github.com/ipython/ipython/blob/master/IPython/extensions/tests/test...
Of course, they could/should be included in the moving. I could refactor them to remove Nose as a requirement, but obviously IPython (probably few versions) would be mandatory to run them.
Yes, getting rid of nosetest looks simple enough. We have our own test runner in runtests.py that also runs unit tests. We could install IPython on our CI server to run the tests there, so I don't see a problem with it (as long as the tests do *not* run if IPython is not available, e.g. on Travis). Stefan
On Sun, Apr 6, 2014 at 4:18 AM, Stefan Behnel <stefan_ml@behnel.de> wrote:
Would it be ok to expose the "load_ipython_extension()" function directly on the Cython package? Then you'd just say "%load_ext Cython". I suggest to drop the implementation into Cython/Build/IPythonMagic.py and import it from there inside of "load_ipython_extension()". There is a "Tests" package in there as well.
Ok, it sounds very good. Simpler for users with low "pollution" for cython.
Yes, getting rid of nosetest looks simple enough. We have our own test runner in runtests.py that also runs unit tests.
We could install IPython on our CI server to run the tests there, so I don't see a problem with it (as long as the tests do *not* run if IPython is not available, e.g. on Travis).
Great. So, should I start the pull request and continue the discussion in the context of the code? There is something I must to read before "contribute to cython" ? Thanks a lot for your answers Martin -- mgaitan.github.io textosyprextextos.com.ar
Martín Gaitán, 14.04.2014 00:06:
On Sun, Apr 6, 2014 at 1:26 PM, Martín Gaitán wrote:
So, should I start the pull request and continue the discussion in the context of the code?
Hi: ping.
should I?
Sorry, please do! Current master is Py2.6+, so feel free to depend on that. Stefan
participants (3)
-
Martín Gaitán -
Robert Bradshaw -
Stefan Behnel