Eric Firing wrote:
> Michael Droettboom wrote:
>> I appreciate the way it fits so nicely into C++ ideas about RAII and 
>> exceptions -- but if you're not a C++ guy, that pro is probably a con.
> What is RAII?

"Resource Aquisition is Initialization" -- It's a C++ memory management 
technique where all resources are allocated in constructors and 
destroyed in destructors (I'm grossly oversimplifying).  It allows 
memory management to be mostly hidden from the users of classes, and 
exceptions to work as they were intended (without lots of try/catch 
blocks everywhere.)  RAII is not the solution to all memory management 
problems, of course, but it's a pretty common and important rule of 
thumb for C++.  See here for more info:

http://www.parashift.com/c++-faq-lite/big-picture.html#faq-6.18

PyCxx uses RAII to manage the lifetime of Python objects without 
requiring explicit reference counting.  For instance, when you get a 
Py::Int from an argument, the reference count of its "owned" Python 
object is increased in the constructor and decreased in the destructor. 
  So when the Py::Int goes out of scope, it automatically destroys its 
reference to the underlying Python object.

In this way, I see pycxx less as a wrapper mechanism (like SWIG or even 
Boost), and more like C++ convenience and safety extensions to the 
regular Python/C API.  Given my familiarity with the Python/C API, that 
could be why I like it.

> I don't know how well pyrex will be maintained and updated, long-term.

Which, of course, is one of the impetuses (impeti?) for moving away from 
CXX.  We'll have to tread carefully.

>> I suppose my initial disappointment in SWIG is that I like its 
>> fundamental idea -- of automating the tedious boilerplate -- but the 
>> execution of it just seems so heavyweight.  But maybe that doesn't 
>> really matter.  This is Python after all ;)
> 
> I think it is a perfectly valid concern and consideration.

Some benchmarking may be in order.  I think it would be useful to know 
the difference in function call overhead between the different 
approaches, for instance.  And overall memory usage is probably a 
secondary concern.

Cheers,
Mike

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to