-
Notifications
You must be signed in to change notification settings - Fork 17
Support paths for hash and isinstance that does not resolve a Proxy #549
Copy link
Copy link
Closed
Labels
enhancementNew features or improvements to existing functionalityNew features or improvements to existing functionality
Description
Describe the Request
Hashing an object or checking its type is idiomatic for working with Python objects, but these operations on a proxy have the potentially unintended side effect of resolving the proxy. For example, the Dask scheduler both hashes a proxy inputs and checks their type, which can cause a proxy to be resolved twice---once on the scheduler and once on the worker.
It would be helpful to have an opt-in execution path that caches the type and hash of a target in the proxy to avoid incidental resolves when using common operations on the proxy.
This will require some new parameters to be added to Proxy() and subsequently Store.proxy(). It might be helpful as a result to have those flags set as defaults on the Store.
Sample Code
target = 42
factory = lambda: target
proxy = Proxy(factory, precompute_from_target=target)
with Store(...) as store:
proxy = store.proxy(target, precompute_defaults=True, populate_target=True)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew features or improvements to existing functionalityNew features or improvements to existing functionality