[Tutor] Const on Python

Andreas Kostyrka andreas at kostyrka.org
Sat Mar 8 03:16:40 CET 2008

Am Freitag, den 07.03.2008, 21:13 +0000 schrieb Alan Gauld:
> Yes but thats not the bit that takes time in my experience its
> trying to understand the problem. What exactly am I trying to
> do here? Is it a suimulation exercise, a database problem?
> A real-time or networking issue? Should my solution include
> security protection? If so how much? Can I use a standard
> sort or do i need a custom algorithm? And if so what is it?
> Designing an algorithm takes far longer than converting it to
> code in any language.

Right, but I've encountered it more than once in my professional life,
that the C++ guys where still trying to implement a simple algorithm,
while I was already finetuning a 2nd or 3rd generation of code.

And while it's not always a magnitude, and it's hard to measure, the few
times where I had to ability to compare (either because I was working
parallel or was replacing a failed C++ project), a magnitude seems to
describe the difference in development efficiency.

And this incremental improvements is the usual way, because without a
working prototype it's hard (and partially foolish) to decide which
parts of the design need improvements. (Remember, "Good-Enough" is the
relevant criteria when it comes to performance, so designing and
implementating the best algorithm from scratch does not make sense
(because often vastly simpler algorithms can provide the needed
performance, and again, it's really hard to guess which parts will be
critical for the performance)

> > So Python speeds up the thinking part.
> It speeds up the thinking abouit code bit, it doesn't help much
> in the thining about the problem part.

You are forgetting a critical part. When speaking about coding, I'm
talking about writing the code, and getting it reasonable
bugfree/usable. And that's where Python shines. 

> > As far as the code, those 20-100 lines will do more if they are in
> > Python than they will if they are in Java or C++.
> Absolutely, thats why I write in Python and let the developers
> do the Java stuff - life is too short! And thats why I am on a
> Python mailing list not a Java one :-)
> > I don't see an order of magnitude difference between
> > Python and Java
> And thats my point, particularly for bigger projects where
> the problem complexity completely dominates the code
> complexity. The coding time will derinitely improve and I
> suspect you could get as high as 4 or 5 times but I doubt
> if you'd ever really achieve an order of magnitude.

Actually, the project where I achieved over a magnitude speedup was
highly complicated, involved partial reverse-engineering of binary
formats, embedding Python in a C++ app, refactoring the C++ app to
support multiple input handlers, doing a framework, optimizing,
portability to all kind of old UNIX boxes (the app had designed minimum
life cycle of 30 years), ...

The C++ guys gave up in disgust after more than 9 months into the
project. I had overtaken all their tries after one month. OTOH, if I'd
compare me with the designed time for the project (which was 12 months),
I have been only 2-3 times as fast as management had planned. In
practice, the C++ guys had massive problems, and if their progress had
been any measure, they would have taken at least 24-30 months getting
the project going. I know it's unnice, because the project had not
complete specifications (well, management claimed that it had all specs
needed, as it happens the more important half of the specs needed to be
reverse engineered. With data files in the MB range, manual decoding was
not an workable solution. But the experimenting wasn't that bad with for
me, while the C++ guy never reached the point where deciphering the
semantic meaning of the data was relevant to them.)

So I stand by the "magnitude" of developer efficiency difference. It's
not there for every project, but OTOH there are other projects where you
can get even more speedup. (Don't you have ever listened in on projects
that are infrastructure building that is just, well, a nonissue in

And btw, it's not just Python, it just happens to me my default
language. Highlevel languages do "pay", and it's starting to show slowly
in the industry. (Well, 1-2 years ago, my CV was "optimized" to for
non-Python experience. The last year, I've been usually able to pick
Python contracts without much of troubles, so Python is growing in
commercial settings.)

> > have compared code samples, I have found Python code
> > to be 20-60% the size of equivalent Java code.
> In the few cases I've measured its been about 30% less
> which nearly falls into your range. But the examples were very
> small - all less than 1000 lines of Java - about as much
> Java as I can bring myself to type!

Well, Java is already a relative "high-level" language, it's basically
safe, which helps debugging greatly, and is being made into something
even more highlevel by all kinds of IDE wizards. I wouldn't expect a
magnitude between Java/Python, just because Java is way nearer to Python
than that it is to C++. (Despite the syntax.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.python.org/pipermail/tutor/attachments/20080308/a3d85179/attachment-0001.pgp 

More information about the Tutor mailing list