I've got it and that fixes the issue.
Thanks

2009/4/6 Sean Gillies <[email protected]>

> Apologies, I provided a wrong URL. The code is at
>
> http://svn.gispython.org/svn/gispy/Shapely/branches/1.0/
>
> Get it like
>
>   $ svn co http://svn.gispython.org/svn/gispy/Shapely/branches/1.0/
> Shapely-1.0
>
> or use RapidSVN.
>
> To test the code without installing it, start a python interpreter
> from the Shapely-1.0 directory and check that an imported shapely
> comes from the correct file:
>
>   $ cd Shapely-1.0
>   $ python
>   >>> import shapely
>   >>> shapely.__file__
>   'shapely/__init__.pyc'
>
> Sean
>
> On Apr 6, 2009, at 2:51 AM, Pascal Leroux wrote:
>
> > Hi Sean. Glad to have helped ! I've tried to download r1225 but I'm
> > not used to work with Subversion. I've used RapidSvn but I've got
> > the error message "Could not open the requested SVN filesystem". Is
> > any login/password needed ?
> >
> > Pascal
> >
> > 2009/4/5 Sean Gillies <[email protected]>
> > Hi Pascal, thanks for tracking this down. Would you be willing to
> > download r1225 from the Shapely 1.0 branch? I've got a fix for the
> > various binary op/topology descriptors that keeps the reference counts
> > down to 2.
> >
> > http://svn.gispython.org/svn/Shapely/branches/1.0
> >
> > On Apr 5, 2009, at 7:22 AM, Pascal Leroux wrote:
> >
> > > Hi Sean,
> > >
> > > I think I've found what's going wrong with the references.
> > >
> > > (the line numbers below correspond to the official release 1.0.11)
> > >
> > > I added in shapely/geometry/base.py, after line 266 (in __del__
> > > method of the BaseGeometry)
> > > print "__del__ %x" % id(self)
> > > to see when a geometry instance is actually freed
> > >
> > >
> > > >>> from sys import getrefcount as grc
> > > >>> from shapely.geometry import Point
> > > >>> p=Point((0,0))
> > > >>> grc(p)
> > > 2
> > >
> > > Python documentation says that's ok to find +1 for the result that
> > is
> > > evaluated inside the function/method. So reference count is 1
> > >
> > > >>> "%x" % id(p)
> > > 'b7e72e8c'
> > > >>> del p
> > > __del__ b7e72e8c
> > >
> > > As soon as the reference count equals 0, __del__ is called
> > >
> > > >>> p=Point((0,0))
> > > >>> "%x" % id(p)
> > > 'b7e72e8c'
> > > >>> p.intersection
> > > <shapely.topology.BinaryTopologicalOp object at 0xb7d34cac>
> > > >>> grc(p)
> > > 3
> > > >>> id(p)-id(p.intersection.context)
> > > 0L
> > >
> > > In the "__get__" method of class BinaryTopologicalOp (line 25,
> > > topology.c),
> > > self.context that was None, now equals my point p
> > > There's one more reference and the last statement above shows that
> > > the new
> > > reference is p.intersection.context
> > >
> > > >>> res = p.intersection(Point((9,9)))
> > > __del__ 94e428c
> > > >>> grc(p)
> > > 4
> > > >>> id(p)-id(p.intersection.context)
> > > 0L
> > >
> > > A new "call" to "__get__" decrements AND re-increments : reference
> > > count doesn't change
> > >
> > > >>> id(p)-id(res.__p__)
> > > 0L
> > > >>> del p.intersection.context
> > > >>> grc(p)
> > > 3
> > >
> > > When the function geom_factory is called, a new reference to the
> > > point is done
> > > "ob.__p__ = parent" (base.py, line 45) with "parent" that is my
> > > initial "p"
> > >
> > > >>> del res.__p__
> > > >>> grc(p)
> > > 2
> > > >>> del p
> > > __del__ b7e72e8c
> > > >>>
> > >
> > > When I explictely call "del res.__p__", the "p" reference count is
> > > OK (2-1)
> > > __del__ is now called after the last "del p"
> > >
> > >
> > > I think that this problem occurs for all the geometries (they are
> > > all (?) derived from BaseGeometry).
> > > And that explains the issue I posted last week and those of
> > yesterday.
> > >
> > > Do you think it's correct ?
> > >
> > > Pascal
> > >
> > >
> > >
> > >
> > > 2009/4/4 Pascal Leroux <[email protected]>
> > > Hi Sean,
> > >
> > > 2009/4/4 Sean Gillies <[email protected]>
> > >
> > > Hi Pascal,
> > >
> > > This cries out for a cascaded union, I think. Maybe we should have a
> > > 1.0.12 release. Still, the leaks trouble me. Statements like
> > >
> > >   P = P.union(p)
> > >
> > > have caused me problems in the past. Probably a matter of held
> > > references? Any interest in digging into it?
> > >
> > > Of course I'm interested in finding what's going wrong. But I've
> > > using Python (and Shapely) for less than a year (my first mail to
> > > the mailing list was posted in last July) and I think my knowledge
> > > in Python is not big enough, especially for Python/C interface, to
> > > fix the issue.
> > >
> > > But I'm trying to get into your code and learn how Shapely works. I
> > > would be so sad to have to work again with C/libgeos. Once again,
> > > Shapely saves me time (thanks !) and I've taught my colleagues
> > > (Institut Géographique National, France) to use Python and Shapely
> _______________________________________________
> Community mailing list
> [email protected]
> http://lists.gispython.org/mailman/listinfo/community
>
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to