Conversation
217b537 to
96a54b0
Compare
|
I rebased this PR on current |
|
actually...
|
Hm, I missed that. I think it doesn't make sense, since
Yes, this way we'll end up with multiple |
pygeodiff/main.py
Outdated
| def __del__(self): | ||
| self.shutdown() | ||
|
|
||
| def _lazy_load(): |
There was a problem hiding this comment.
An unsolicited comment from me.
You could use Python's @property decorator here to simplify the lazy loading.
https://realpython.com/python-property/
It would look something like this.
def __init__(self, libname=None):
...
self._clib = None
self._context = None
@property
def clib(self):
if self._clib is None:
self._clib = GeoDiffLib(self.libname)
return self._clib
@property
def context(self):
if self._context is None:
self._context = self.clib.create_context()
context.callbackLogger = None
return self._context
def shutdown(self):
self.clib.destroy_context(self.context)
self._clib = None
self._context = NoneThis means that you don't have to call _lazy_load all the time, as the propery creates the clib and context when they are first accessed. It does mean that the shutdown function will create new clib and context just to destroy them if you call it before you have used them elsewhere.
pygeodiff.shutdown()to correctly unload on windowspygeodiff.GeoDiff()latest python had some problems with comments with
\so I replaced it with:fix #205