Skip to content

Support paths for hash and isinstance that does not resolve a Proxy #549

@gpauloski

Description

@gpauloski

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)

Metadata

Metadata

Assignees

Labels

enhancementNew features or improvements to existing functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions