Why is python not written in C++ ?

Roy Smith roy at panix.com
Tue Aug 3 04:46:50 CEST 2010


In article 
<7d95c0d3-718d-4958-9364-263c833f1835 at i24g2000yqa.googlegroups.com>,
 sturlamolden <sturlamolden at yahoo.no> wrote:

> On 3 Aug, 02:47, Roy Smith <r... at panix.com> wrote:
> 
> > This one I don't understand.  Yes, I get RAII, but surely there are
> > valid reasons to allocate memory outside of constructors.  Containers
> > which resize themselves (such as std::vector) are one obvious example.
> 
> That is because an exception might skip an arbitrarily placed delete[]
> or std::fclose when it rewinds the stack...

Well, OK, but there's still nothing wrong with allocating memory outside 
of constructors, as long as you make sure the destructor cleans it up.  
Or you have made some other arrangements to make sure it's cleaned up 
(try/catch, auto_pointer, etc).



More information about the Python-list mailing list