Closed hhsecond closed 3 years ago
It would depend on the implementation. I guess I could add a standard way of telling if it holds the instance or not (like obj.__instance__
or similar) but why do you need this anyway?
Thinking more about this, a __isresolved__
bool would be better.
Hi @ionelmc, First of all, thanks a lot for taking your time here. I can't express how grateful I am (and so is the folks using your project)
About your suggestion, __isresolved__
sounds better to me too.
So my need is a bit involved in the architecture level but the gist is here
I have python processes (nodes) composed as DAGs. I prefetch the datapoints from database and provide them as lazy proxies to these nodes. These nodes can use these data points to do different operations but a writer process kept on checking the data changes and write it back to the database. Currently, the assumption I have taken is that, if the data is not resolved then the data is not changed. So I can avoid expensive writes.
While my requirement is quite peculiar, I thought the functionality to check proxy-resolution is quite useful and widely being used already. Currently what I do is to use simple.Proxy
and check
"__wrapper__" in proxyobj.__dict__
So I would like to add this property in the next release but I'm not sure about the name. It has to be something unique enough and double underscored (to increase uniqueness). It has to avoid british/american spelling differences, and be pretty obvious.
My candidates:
__isresolved__
- bad because of ambiguous spelling - is it resolved or rezolved? who knows__resolved__
- same problem, and also, I wonder if it's worth having the "is" prefix at all__materialized__
- same problem (materialised), also kinda long__completed__
__instantiated__
- kinda long, but very good otherwise__has_instance__
- still long__reified__
- short, unique but kinda obscure?__formed__
- maybe not very obvious of what it'd represent?Hmmm... perhaps there's some terminology already established in the stdlib?
On second thought perhaps reusing terms from stdlib would be a bad idea. So I've found __cached__
which would seem suitable but would conflict with the interface here https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module
How about __called__
or even __factory_called__
(no confusion about if it means that __call__
was used)?
So turns out no one spells "rezolved". Anyway, not using the "is" prefix as it seems to have a "call interface" in the stdlib (eg: somestr.isdigit()
).
Thanks a lot for the wonderful package I was wondering if there is a mechanism to check whether the factory function is being called or not, may be allowing to check?