Article of interest: Python pros/cons for the enterprise

Lou Pecora pecora at anvil.nrl.navy.mil
Sun Feb 24 11:11:18 EST 2008


In article 
<d7a77bf9-4e9c-42a3-8a3c-60d12690560b at c33g2000hsd.googlegroups.com>,
 Nicola Musatti <nicola.musatti at gmail.com> wrote:

> On Feb 22, 12:07 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> > Nicola Musatti <nicola.musa... at gmail.com> writes:
> > > In C++ memory is just another resource which you can handle just like
> > > any other one, possibly using RAII.
> >
> > Ok, I'll bite.  Here's a straightforward Python expression:
> >
> >    a = [f(x) + g(y) for x,y in izip(m1, m2) if h(x,y).frob() == 7]
> >
> > Consider how many intermediate objects are being allocated in figuring
> > out that listcomp.  Do you REALLY want to manage all the deallocation
> > with something like RAII?
> 
> 
> What makes you think that a translation of a similar expression would
> involve explicit dynamic allocation at all? Barring bugs, here's an
> equivalent example:
> 
> #include <iostream>
> #include <map>
> #include <vector>

[cut a lot of C++ code]

I realize the original point was about dynamic allocation and GC, but 
for me the raw juxtaposition of the *one* line of clear Python code with 
the equivalent mass of C++ code is shocking.  Thanks for that.

-- 
-- Lou Pecora



More information about the Python-list mailing list