Inheritance of Purity
See original GitHub issue(As discussed here: http://stackoverflow.com/questions/42773134/inheritance-of-purity/42773643)
I have a question about inheritance of function purity. For example, consider this case:
In [1]: from dask import delayed
In [2]: myArr = delayed(np.ones, pure=True)((10,10))
In [3]: myArr
Out[3]: Delayed('ones-850ff41a84b309775d01d5f3e5c4d1c4')
In [4]: myArr = delayed(np.ones, pure=True)((10,10))
In [5]: myArr
Out[5]: Delayed('ones-850ff41a84b309775d01d5f3e5c4d1c4')
In [6]: myArr.shape
Out[6]: Delayed('getattr-de14f312-2605-4fc4-a419-c376520f73b4')
In [7]: myArr.shape
Out[7]: Delayed('getattr-9e547a62-0bc6-43e5-8d3c-cac532b73511')
In [8]: delayed(getattr, pure=True)(myArr, 'shape')
Out[8]: Delayed('getattr-5224be928bad33c9778d4f96d610cc37')
In [9]: delayed(getattr, pure=True)(myArr, 'shape')
Out[9]: Delayed('getattr-5224be928bad33c9778d4f96d610cc37')
I would expect line [6] and [7] to yield the same key, since they are accessing an attribute from a delayed instance declared pure. However, it is not the case, and I must explicitly declare the getattr
method to be pure for this to work, as seen in lines [8] and [9].
As discussed in the stackoverflow link, this seems to be purely an issue of dask
semantics. I would be inclined to voting for purity to be inherited. But I am a new user, so I would appreciate feedback/comments on this. Thanks!
PS: The eventual use case is for dask distributed. It seems that the way purity is treated in this case may possibly be different than the case listed here.
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
I applied my proposal above in #2084. I think this is internally consistent, so this approach would be my vote.
Thanks, I vote for this as well 😃. I like the elaborated documentation, very useful as well!