3D graphics programmers using Python?

Alex Martelli aleax at aleax.it
Fri Feb 7 04:30:08 EST 2003


Peter Hansen wrote:
   ...
> argue that the use of C++ is practically never the right choice, as one
> could always more effectively use C (for those cases where performance
> or closeness-to-hardware requires it) or Python (for all else).  I

Let me play devil's advocate: I can code a Python extension in
e.g. 200 lines of C, with much manual fiddling of reference
counts and substantial risk of some reference count related
bug; or I can code it in say 50 lines of C++ thanks to Boost
(and C++'s powerful standard library), with automatic help
for all reference count handling &c and thus fewer bug risks.

So all in all, *IF* I know C and C++ perfectly to start with
(and the study thereof is taken as already amortized), I can
have 4 or 5 times the productivity in C++ than in C, for this
task.  Indeed, interfacing to Python is an excellent use case
for C++ vs C, thanks to Boost's power.  I can get just as good
performance in C++ as I can in C (or better, see Blitz++) and
ditto for "closeness to the hardware".

Thus, I disagree about "practically never the right choice".
The only real issue is thast "*IF*" -- needing perfect knowledge
of both languages (I strongly disagree with people who think you
can effectively "subset" C++ in practical use).  If you write a
*LOT* of Python extensions (etc), then presumably the extra cost
of studying C++ (much more complicated than C) gets amortized.

But, it IS a lot of study.  If one already knows C perfectly,
and must do some (but not a whole lot of) extension development,
then studying C++ for the purpose may not pay for itself.  That,
in my opinion, is the tradeoff of interest between C and C++.


Alex





More information about the Python-list mailing list