[Cython] PXD file for overriding math functions
Ok, I think I am missing something - I am a bit lost in the Cython jargon. Here is where I stand, let me know where I am going wrong... I compiled with cython.py -a test.py, but it isn't working. If I am completely not on the right track, feel free to let me know :) Ian # test.py (Pure python file) # from math import sin def f(r): s=sin(r) return s r=3.141592654/3.0 print f(r) test.pxd # cimport cython import cython cimport math_override @cython.locals(s=cython. double) cpdef f(double r) math_override.pxd # cdef extern from "math.h": double sin_d "sin" (double x) float sin_f "sin" (float x) cpdef inline double sin(double x): return sin_d(x) cpdef inline float sin(float x): return sin_f(x) ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
[Cython] Suggestion of adding working examples to website
One "feature" that matplotlib (Python's 2D plotting library) has which makes it easy to jump into matplotlib is the huge section of working examples: http://matplotlib.sourceforge.net/examples/index.html and http://matplotlib.sourceforge.net/gallery.html . From this, within a couple of days you can get minimally proficient with matplotlib. Having been (and continuing to be) a new user of Cython, I have found the learning curve to be very steep. The documentation online is pretty good (though it could use some work in places). Sometimes all it would take would be some working examples and the documentation would be completely clear. I taught myself the use of matplotlib through the old cut&paste and iterate method. I find that the one thing that is consistently the most challenging about the Cython docs is the lack of distutils setup.py files for more interesting configurations. Without them it requires a certain amount of guessing, playing, and Googling to make sense of how the pieces are supposed to go together. A working examples section could be VERY helpful in this regards. Also, the options for the distutils extensions are not documented at all so far as I can tell. Since the docs were built with Sphinx, it ought to be pretty easy to pull in docstrings if they exist. Just my 2 cents. I would be happy to work with you all to compile some simple examples for common uses - like the numpy convolve example for instance, and the integration example as well. Regards, Ian ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
[Cython] Resurrecting __dict__ for extension types
As per a couple of discussions online ( http://mail.python.org/pipermail/cython-devel/2011-February/000122.html), it looks like at one point it was pretty close to being able to programmatically and automatically generate a __dict__ for extension types like for CPython classes. I have to manually code a function that does exactly what __dict__ should do, and it is a pain. I have some classes with tens of attributes, and that is already a big enough pain. This is especially useful to more easily enable deepcopy and pickling for classes. While on the pickling theme, it seems it really ought to be pretty straightforward to automatically pickle extension types. Don't you already have all the necessary information at compile time? This was on the wish list at one point if I am not mistaken and would be very useful to me and lots of other people. I'm finally loving coding in Cython and am finally making sense of how best to use extension types. Regards, Ian ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
[Cython] Auto-pickle progress?
There is a proposal for auto-pickling of Cython extension types: http://wiki.cython.org/enhancements/pickling I was wondering whether there has been any progress on this front? Auto-pickling would be tremendously helpful as pickling and unpickling is one of the most annoying features of working with threads and processes in python. Regards, Ian ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Auto-pickle progress?
I agree that some of the more powerful elements of Cython would be/are difficult or impossible to pickle in a general way. I have a counter use-case where auto-pickling would be very useful. I have cdef classes that have many (think 50-100) members of double and long types, as well as other cdef classes that are also only using Cython-friendly data types. I have implemented pickling for these classes and it sucks. Trying to maintain the list of parameters that need to be pickled is a major hassle. The biggest problem is that if you add add a parameter to the class but forget to add it to the pickling function, you end up with the parameter not getting reloaded on unpickling. This is not good! Yes it is up the programmer to do this right, but I could use some help. What I have ended up doing for my other classes is define a __cdict__ function that returns a dictionary with the values and parameters as defined in the cdef class. In this way, pickling and unpickling is a little bit more pleasant. But it would be fantastic if the __cdict__ could be baked into the class automatically. It would be fine for me if only the things that could be easily handled would be returned, and a second list of attributes that require more work to be serialized so that the user/coder could be sure that all the attributes are being handled and none get forgotten. Also, the docs on pickling of cdef classes is very sparse, a simple example would be very beneficial. The is one in the examples in the source, but it is not easy to find Ian On Tue, Sep 25, 2012 at 6:44 AM, Sturla Molden wrote: > On 20.09.2012 21:11, Ian Bell wrote: > > Auto-pickling would be tremendously helpful as pickling and unpickling >> is one of the most annoying features of working with threads and >> processes in python. >> > > How should Cython interfere how to pickle a C pointer? > > cdef class foobar: > cdef double *data > > A C object can be anything. Cython does not know anything about size, > offset or strides, or even if it's safe to take a copy. > > Example: How to pickle a shared memory buffer? Surely we cannot take a > copy, because that would defeat the purpose of "shared" memory. And even if > could take a copy, how many bytes should be copied? Do you think an > autopickler could have figured this out? > > https://github.com/**sturlamolden/sharedmem-numpy/**blob/master/sharedmem/ > **sharedmemory_sysv.pyx<https://github.com/sturlamolden/sharedmem-numpy/blob/master/sharedmem/sharedmemory_sysv.pyx> > > https://github.com/**sturlamolden/sharedmem-numpy/**blob/master/sharedmem/ > **sharedmemory_win.pyx<https://github.com/sturlamolden/sharedmem-numpy/blob/master/sharedmem/sharedmemory_win.pyx> > > On yes, the code is different on Unix and Windows, something the > auto-pickler could not possibly know either. > > Auto-pickling cdef classes is not doable, IMHO. > > > And by the way, implementing a __reduce__ method manually is not very > difficult either. > > > Sturla Molden > > __**_ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/**mailman/listinfo/cython-devel<http://mail.python.org/mailman/listinfo/cython-devel> > ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
[Cython] Test/example for cpdef enum
Are there any tests/docs/examples showing how to use the cpdef enum? This is a feature I have been looking for for a long time and I am hoping to use it very soon in my own project. I have a windows box that I can run the alpha test suite on with the full complement of python versions. Let me know if there is interest and I can run the tests. Alternatively, if you are still doing a buildbot (the link at https://github.com/cython/cython/wiki/HackerGuide#buildbot is broken) , we could configure a nightly slave to run the tests. ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Test/example for cpdef enum
On Sat, Aug 2, 2014 at 7:42 PM, Matthew Brett wrote: > On Sat, Aug 02, 2014 at 10:08 AM, Robert Bradshaw > wrote: > > > from: Robert Bradshaw > > date: Sat, Aug 02 10:08 AM -07:00 2014 > > to: Core developer mailing list of the Cython compiler < > cython-devel@python.org> > > reply-to: Core developer mailing list of the Cython compiler < > cython-devel@python.org> > > subject: Re: [Cython] Test/example for cpdef enum > > > > On Sat, Aug 2, 2014 at 3:56 AM, Ian Bell wrote: > >> Are there any tests/docs/examples showing how to use the cpdef enum? > This > >> is a feature I have been looking for for a long time and I am hoping to > use > >> it very soon in my own project. > > > > https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pyx > > https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pxd > > > >> I have a windows box that I can run the alpha test suite on with the > full > >> complement of python versions. Let me know if there is interest and I > can > >> run the tests. Alternatively, if you are still doing a buildbot (the > link > >> at https://github.com/cython/cython/wiki/HackerGuide#buildbot is > broken) , > >> we could configure a nightly slave to run the tests. > > > > That would be nice; windows is woefully undertested for Cython. > > Another big 'that would be nice' from me. > > We (the berkeley / nipy team) have a buildbot set up you could hook into > if you need one. The configuration is all on github at > https://github.com/nipy/nibotmi , and you are welcome to access to the > build master to play with configuration if you'd like. > > Can you set me up a nightly build (once per 24 hours) and we can then iterate on getting things functional on my box to the level that is needed. I use anaconda for instance which might cause issues - I briefly saw you use virtualenv. Ian > Cheers, > > Matthew > > -- > Sent from Vmail > > ___ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel > > ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Test/example for cpdef enum
On Sat, Aug 2, 2014 at 7:08 PM, Robert Bradshaw wrote: > On Sat, Aug 2, 2014 at 3:56 AM, Ian Bell wrote: > > Are there any tests/docs/examples showing how to use the cpdef enum? > This > > is a feature I have been looking for for a long time and I am hoping to > use > > it very soon in my own project. > > https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pyx > https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pxd > I see. Stupidly I had thought that it would be automatic in the sense that you don't have to manually declare which parameters will be output in the python module. Evidently that is not the case, which I guess is ok. I had hoped to avoid my script which parses my header and make a constants module. It works fine, its not the prettiest, but I guess I won't be saying goodbye to it any time soon. > > > I have a windows box that I can run the alpha test suite on with the full > > complement of python versions. Let me know if there is interest and I > can > > run the tests. Alternatively, if you are still doing a buildbot (the > link > > at https://github.com/cython/cython/wiki/HackerGuide#buildbot is > broken) , > > we could configure a nightly slave to run the tests. > > That would be nice; windows is woefully undertested for Cython. > > - Robert > ___ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel > ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Test/example for cpdef enum
On Tue, Aug 5, 2014 at 1:16 AM, Matthew Brett wrote: > Hi, > > On Mon, Aug 4, 2014 at 4:11 PM, Ian Bell wrote: > > > > > > > > On Sat, Aug 2, 2014 at 7:42 PM, Matthew Brett > > wrote: > >> > >> On Sat, Aug 02, 2014 at 10:08 AM, Robert Bradshaw > >> wrote: > >> > >> > from: Robert Bradshaw > >> > date: Sat, Aug 02 10:08 AM -07:00 2014 > >> > to: Core developer mailing list of the Cython compiler > >> > > >> > reply-to: Core developer mailing list of the Cython compiler > >> > > >> > subject: Re: [Cython] Test/example for cpdef enum > >> > > >> > On Sat, Aug 2, 2014 at 3:56 AM, Ian Bell > wrote: > >> >> Are there any tests/docs/examples showing how to use the cpdef enum? > >> >> This > >> >> is a feature I have been looking for for a long time and I am hoping > to > >> >> use > >> >> it very soon in my own project. > >> > > >> > > https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pyx > >> > > https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pxd > >> > > >> >> I have a windows box that I can run the alpha test suite on with the > >> >> full > >> >> complement of python versions. Let me know if there is interest and > I > >> >> can > >> >> run the tests. Alternatively, if you are still doing a buildbot (the > >> >> link > >> >> at https://github.com/cython/cython/wiki/HackerGuide#buildbot is > >> >> broken) , > >> >> we could configure a nightly slave to run the tests. > >> > > >> > That would be nice; windows is woefully undertested for Cython. > >> > >> Another big 'that would be nice' from me. > >> > >> We (the berkeley / nipy team) have a buildbot set up you could hook into > >> if you need one. The configuration is all on github at > >> https://github.com/nipy/nibotmi , and you are welcome to access to the > >> build master to play with configuration if you'd like. > >> > > Can you set me up a nightly build (once per 24 hours) and we can then > > iterate on getting things functional on my box to the level that is > needed. > > I use anaconda for instance which might cause issues - I briefly saw you > use > > virtualenv. > > Yes, the classes I wrote to make making a build factor a little more > automated use virtualenvs; if you don't want to use those classes, you > can use the bare-metal buildbot build steps with Ananconda on the > slave. But - do you need Anaconda to set up a Cython build test? > Maybe you can use virtualenv with the Anaconda Python? > > So far as I can tell, anaconda and virtualenv don't play too well together. Which is too bad, because I recall having some issues with something (buildbot?) not running happily in an anaconda env > Cheers, > > Matthew > ___ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel > ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Test/example for cpdef enum
On Tue, Aug 5, 2014 at 1:28 AM, Matthew Brett wrote: > On Mon, Aug 4, 2014 at 4:19 PM, Ian Bell wrote: > > > > > > > > On Tue, Aug 5, 2014 at 1:16 AM, Matthew Brett > > wrote: > >> > >> Hi, > >> > >> On Mon, Aug 4, 2014 at 4:11 PM, Ian Bell wrote: > >> > > >> > > >> > > >> > On Sat, Aug 2, 2014 at 7:42 PM, Matthew Brett < > matthew.br...@gmail.com> > >> > wrote: > >> >> > >> >> On Sat, Aug 02, 2014 at 10:08 AM, Robert Bradshaw < > rober...@gmail.com> > >> >> wrote: > >> >> > >> >> > from: Robert Bradshaw > >> >> > date: Sat, Aug 02 10:08 AM -07:00 2014 > >> >> > to: Core developer mailing list of the Cython compiler > >> >> > > >> >> > reply-to: Core developer mailing list of the Cython compiler > >> >> > > >> >> > subject: Re: [Cython] Test/example for cpdef enum > >> >> > > >> >> > On Sat, Aug 2, 2014 at 3:56 AM, Ian Bell > >> >> > wrote: > >> >> >> Are there any tests/docs/examples showing how to use the cpdef > enum? > >> >> >> This > >> >> >> is a feature I have been looking for for a long time and I am > hoping > >> >> >> to > >> >> >> use > >> >> >> it very soon in my own project. > >> >> > > >> >> > > >> >> > > https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pyx > >> >> > > >> >> > > https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pxd > >> >> > > >> >> >> I have a windows box that I can run the alpha test suite on with > the > >> >> >> full > >> >> >> complement of python versions. Let me know if there is interest > and > >> >> >> I > >> >> >> can > >> >> >> run the tests. Alternatively, if you are still doing a buildbot > >> >> >> (the > >> >> >> link > >> >> >> at https://github.com/cython/cython/wiki/HackerGuide#buildbot is > >> >> >> broken) , > >> >> >> we could configure a nightly slave to run the tests. > >> >> > > >> >> > That would be nice; windows is woefully undertested for Cython. > >> >> > >> >> Another big 'that would be nice' from me. > >> >> > >> >> We (the berkeley / nipy team) have a buildbot set up you could hook > >> >> into > >> >> if you need one. The configuration is all on github at > >> >> https://github.com/nipy/nibotmi , and you are welcome to access to > the > >> >> build master to play with configuration if you'd like. > >> >> > >> > Can you set me up a nightly build (once per 24 hours) and we can then > >> > iterate on getting things functional on my box to the level that is > >> > needed. > >> > I use anaconda for instance which might cause issues - I briefly saw > you > >> > use > >> > virtualenv. > >> > >> Yes, the classes I wrote to make making a build factor a little more > >> automated use virtualenvs; if you don't want to use those classes, you > >> can use the bare-metal buildbot build steps with Ananconda on the > >> slave. But - do you need Anaconda to set up a Cython build test? > >> Maybe you can use virtualenv with the Anaconda Python? > >> > > So far as I can tell, anaconda and virtualenv don't play too well > together. > > Which is too bad, because I recall having some issues with something > > (buildbot?) not running happily in an anaconda env > > Maybe it's worth giving it a shot and see if problems arise? > > Am I right in thinking you can install Python.org Python alongside > Anaconda? Maybe you could do that? > > That's right - my current config has two minicondas (32/64 bit) defaulting to py27 along with python.org 27 32 bit which I need to keep around due to the delicate interdependencies of wxpython, python, and cx_freeze for a couple of my projects Cheers, > > Matthew > ___ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel > ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Test/example for cpdef enum
On Tue, Aug 5, 2014 at 1:48 AM, Robert Bradshaw wrote: > On Mon, Aug 4, 2014 at 4:14 PM, Ian Bell wrote: > > > > On Sat, Aug 2, 2014 at 7:08 PM, Robert Bradshaw > wrote: > >> > >> On Sat, Aug 2, 2014 at 3:56 AM, Ian Bell wrote: > >> > Are there any tests/docs/examples showing how to use the cpdef enum? > >> > This > >> > is a feature I have been looking for for a long time and I am hoping > to > >> > use > >> > it very soon in my own project. > >> > >> https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pyx > >> https://github.com/cython/cython/blob/master/tests/run/cpdef_enums.pxd > > > > > > I see. Stupidly I had thought that it would be automatic in the sense > that > > you don't have to manually declare which parameters will be output in the > > python module. Evidently that is not the case, which I guess is ok. I > had > > hoped to avoid my script which parses my header and make a constants > module. > > It works fine, its not the prettiest, but I guess I won't be saying > goodbye > > to it any time soon. > > Yeah, we don't have anything that looks at the actual .h/.c files yet. > Too bad - I guess that's why projects like xdress/SWIG exist - though for the life of me I can't get xdress to work at all. SWIG is great, but not so much from the standpoint of interfacing with other cython code. > ___ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel > ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
[Cython] build failure on windows with 0.21b1 windows py27 x64
A snippet of my failure: lex\Scanners.c(6876) : error C2121: '#' : invalid character : possibly the result of a macro expansion lex\Scanners.c(6876) : error C2146: syntax error : missing ')' before identifier 'ifdef' lex\Scanners.c(6876) : error C2121: '#' : invalid character : possibly the result of a macro expansion lex\Scanners.c(6878) : error C2059: syntax error : 'else' lex\Scanners.c(6888) : error C2059: syntax error : '}' lex\Scanners.c(6902) : error C2121: '#' : invalid character : possibly the result of a macro expansion lex\Scanners.c(6902) : error C2121: '#' : invalid character : possibly the result of a macro expansion soft Visual Studio 9.0\VC\BIN\amd64\cl.exe"' failed with exit status 2 Anyone run into similar problems? ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Publish Windows wheels to PyPI
I volunteered to do this quite some time ago, but at the time there wasn't much interest. The offer still stands though. I have a number of build machines that I could use and are properly configured with all the python versions and compilers needed. I've released other python packages in the same way before. Ian On Mon, Sep 28, 2015 at 3:15 PM, Robert Bradshaw wrote: > On Mon, Sep 28, 2015 at 12:22 AM, Dirk Rothe wrote: > > On Sun, 27 Sep 2015 21:30:21 +0200, Mirth Hickford > > wrote: > > > >> Hi Cython. Please consider publishing wheels for Windows to PyPI [1]. > >> Wheels [2] are a package format that installs more reliably than source > >> distributions, especially on Windows. > > I don't own a Windows machine (and nor do many other Cython devs) so > I'm not sure how to do this (let alone navigate the issue of choosing > the right compiler, etc.) But this'd be a great area for a Window > Cython user to contribute. > > https://github.com/cython/cython/pull/389 was recently merged. > > >> Meanwhile a workaround is to download wheels from Christoph Gohlke's > site > >> [3] a godsend. > > > > Yeah, he's awesome. Excellent work for at least 10 years now. Thanks! > > +1, thanks Christoph! > > > Cython is awesome too, btw ;) > > > >> -M > >> > >> [1] https://pypi.python.org/pypi/Cython/ > >> [2] http://pythonwheels.com/ > >> [3] http://www.lfd.uci.edu/~gohlke/pythonlibs/#cython > > > > ___ > > cython-devel mailing list > > cython-devel@python.org > > https://mail.python.org/mailman/listinfo/cython-devel > ___ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel > ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Manylinux wheels for Cython
Jorrit, maybe in interesting for us? On Mar 7, 2016 6:48 PM, "Matthew Brett" wrote: > Hi, > > I don't know whether y'all have been following over at distutils-sig, > but there's a new distutils PEP that defines a `manylinux` format for > Linux wheels that work on many different x86 Linux distributions: > > https://www.python.org/dev/peps/pep-0513/ > https://github.com/pypa/manylinux > > The latest version of pip will install these, if the client Linux > system is compatible with the manylinux spec: > > https://pip.pypa.io/en/stable/news/ > > I've already built and used manylinux Cython wheels, which y'all are > welcome to test with: > > pip install -f https://nipy.bic.berkeley.edu/manylinux cython > > (The wheels there don't have the right manylinux filenames yet, but > they have the same contents as the ones that would go up to pypi). > > I've already had good use from these wheels in speeding up project > builds into docker containers and virtualenvs, and I'd love to upload > these to pypi. I have permissions on pypi to do this, but I wanted > to check in with y'all first... > > Cheers, > > Matthew > ___ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel > ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel