[Numpy-discussion] Proposed Roadmap Overview
Sat Feb 18 00:18:09 CST 2012
On Fri, Feb 17, 2012 at 8:30 PM, Sturla Molden <firstname.lastname@example.org> wrote:
> Den 18. feb. 2012 kl. 05:01 skrev Jason Grout <email@example.com>:
>> On 2/17/12 9:54 PM, Sturla Molden wrote:
>>> We would have to write a C++ programming tutorial that is based on Pyton knowledge instead of C knowledge.
>> I personally would love such a thing. It's been a while since I did
>> anything nontrivial on my own in C++.
> One example: How do we code multiple return values?
> In Python:
> - Return a tuple.
> In C:
> - Use pointers (evilness)
> In C++:
> - Return a std::tuple, as you would in Python.
> - Use references, as you would in Fortran or Pascal.
> - Use pointers, as you would in C.
> C++ textbooks always pick the last...
> I would show the first and the second method, and perhaps intentionally forget the last.
I can add my own 2 cents about cython vs. C vs. C++, based on summer
I was an intern at Enthought, sharing an office with Mark W. (Which
was a treat. I recommend you all quit your day jobs and haunt whatever
office Mark is inhabiting.) I was trying to optimize some code and
that lead to experimenting with both cython and C.
Dealing with the C internals of numpy was frustrating. Since C doesn't
have templating but numpy kinda needs it, instead python scripts go
over and manually perform templating. Not the most obvious thing.
There were other issues in the background--including C doesn't allow
for abstraction (i.e. easy to read), lots of pointer-fu is required,
and the C API is lightly documented and already plenty difficult.
On the flip side, cython looked pretty...but I didn't get the
performance gains I wanted, and had to spend a lot of time figuring
out if it was cython, needing to add types, buggy support for numpy,
or actually the algorithm. The C files generated by cython were
enormous and difficult to read. They really weren't meant for human
consumption. As Sturla has said, regardless of the quality of the
current product, it isn't stable. And even if it looks friendly
there's magic going on under the hood. Magic means it's hard to
diagnose and fix problems. At least one very smart person has told me
they find cython most useful for wrapping C/C++ libraries and exposing
them to python, which is a far cry from library writing. (Of course
Wes McKinney, a cython evangelist, uses it all over his pandas
In comparison, there are a number of high quality, performant,
open-source C++ based array libraries out there with very friendly
API's. Things like eigen
(http://eigen.tuxfamily.org/index.php?title=Main_Page) and Armadillo
(http://arma.sourceforge.net/). They seem to have plenty of users and
more devs than numpy.
On the broader topic of recruitment...sure, cython has a lower barrier
to entry than C++. But there are many, many more C++ developers and
resources out there than cython resources. And it likely will stay
that way for quite some time.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion