[OT] fortran lib which provide python like data type

Rustom Mody rustompmody at gmail.com
Fri Jan 30 11:27:02 EST 2015


On Friday, January 30, 2015 at 1:03:03 PM UTC+5:30, Christian Gollwitzer wrote:
> Am 30.01.15 um 02:40 schrieb Rustom Mody:
> > FORTRAN
> > 
> >  use dictionary
> >  type(dictionary), pointer :: d
> >  d=>dict_new()
> >  call set(d//'toto',1)
> >  v = d//'toto'
> >  call dict_free(d)
> > 
> > The corresponding python
> > 
> >  d = dict()
> >  d['toto'] = 1
> >  v = d['toto']
> >  del(d)
> > 
> > In particular note the del in the python.
> > 
> > Should highlight the point that languages with gc, support data structures
> > in a way that gc-less languages - Fortran, C, C++ - do not and cannot.
> 
> For C++ this is not correct. Ususally a garbage collector is not used -
> though possible - but the constructor/destructor/assignment op in C++
> (usually called RAII) provide semantics very similar to the CPython
> refcounting behaviour.

You may be right... Dont claim to be able to wrap my head round C++
However...

> 
> For example, I made a set of C++ interface methods to return nested
> dicts/list to Python, which is far from complete, but allows to write
> something like this:
> 
> SWList do_something(SWDict attrs) {
>   SWList result;
>   for (int i=0; i<5; i++) {
>     SWDict entry;			
>     entry.insert("count", i);
>     entry.insert("name", "something");
>     result.push_back(entry);
>   }
>   return result;
> }
> 
> 
> There is also Boost::Python which does the same, I think, and much more,
> but only supports Python, whereas I use SWIG to interface these
> dicts/lists to both CPython and Tcl.
> 
> You cannot, however, resolve certain cyclic dependencies with pure
> reference counting.

... if I restate that in other words it says that sufficiently
complex data structures will be beyond the reach of the standard
RAII infrastructure.

Of course this only brings up one side of memory-mgmt problems
viz. unreclaimable memory.

What about dangling pointers?
C++ apps are prone to segfault. Seems to suggest
(to me at least) that the memory-management infrastructure
is not right.

Stroustrup talks of the fact that C++ is suitable for lightweight
abstractions. In view of the segfault-proneness I'd say they 
are rather leaky abstractions.

But as I said at the outset I dont understand C++



More information about the Python-list mailing list