Why I love Python: More rambling...

Georgy Pruss SEE_AT_THE_END at hotmail.com
Sat Nov 1 10:12:17 CET 2003


"Fernando Perez" <fperez528 at yahoo.com> wrote in message news:bnu7ck$aaa$1 at peabody.colorado.edu...
> Alex Martelli wrote:
>
> > Ville Vainio wrote:
> >> Another aspect of motivation is accomplishment - a thing that might
> >> make a C++ programmer proud of his achievement seems like a trivial 15
> >> minute job for a Pythonista, and when that Pythonista is tasked w/ the
> >> C++ job he doesn't get the kick from the accomplishment. And 6 hours
> >> of debugging that "trivial" program doesn't help either.
> >
> > Yep.  Managing to write even just "SPQR" with the marble and chisel
> > without cracking the slab makes you proud (that Q is _so_ tricky!) --
> > with a word processor, or pen and paper, you'd get no kick from the
> > accomplishment.  And six hours of sandpapering and polishing that
> > marble slab doesn't help either.
>
> Data point (real world, from a few weeks ago): after spending ~2 weeks (spread
> over a month) writing about 1400 lines of C++, debugging a nasty coredump, and
> pounding the documentation, I had my 'fast' extension module finished for some
> numerical work.  Great, sweaty and exhausted but all proud of myself, I turn
> my attention to the problem of writing a unittest.  I decided to write it in
> python, since I figured it would be easier, and an independent implementation
> of the algorithm (simple one) should suffice, if tested with enough random
> data.
>
> Python code: 15 lines (no, it's NOT a typo: fifteen).  Time to write it: 10
> minutes.
>

For a J programmer (www.jsoftware.com) it might as well be just a hundred
characters and half an hour.

Regards,
G-:


> The sad part (to my ego, at least:)?  The python runs faster!  The C++ version
> is now in the dustbin.  At least I learned a bunch about the STL and
> templates.  The consolation...
>
> Cheers,
>
> f.
>
> ps for those thinking: you must be an idiot of a C++ programmer. That may well
> be true.  But still, there are reasons for the difference.  The C++ version
> uses a heavily templated library for handling multidimensional arrays with a
> bearable syntax, and g++ isn't the best compiler out there for that kind of
> code.  The python version relies on Numeric.innerproduct(), which is very well
> optimized, and tackles head-on the problem I was avoiding with the templates,
> namely very annoying pointer manipulations for multidimensional tensors.  The
> Numeric guys got their hands dirty, did it once RIGHT, and it works extremely
> well.






More information about the Python-list mailing list