Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable deep hashing if memoization is off #2007

Merged
merged 9 commits into from Oct 23, 2017
Merged

Conversation

philippjfr
Copy link
Member

Currently Callable runs deep hashing on the stream values whether or not memoization is enabled. This PR simply disables it when memoization is off, which has no effect but can be more efficient.

@jlstevens
Copy link
Contributor

Simple change that does make sense.

@philippjfr
Copy link
Member Author

Simple change that does make sense.

Unfortunately it breaks some things. I'll have to think more about it.

@philippjfr
Copy link
Member Author

Okay figured it out, the memoize parameter was being abused by modifying it. I've now added an internal attribute that is used for this purpose instead and the Callable.memoize is now used solely to control whether memoization is enabled or not.

@jlstevens
Copy link
Contributor

Sounds like the right fix.

That said it might be nice to give the concept a different name than self._memoize that helps express the other purposes you mention - otherwise it isn't clear why there is an underscore attribute of the same name that is distinct from the parameter.

@jlstevens
Copy link
Contributor

jlstevens commented Oct 22, 2017

How about _stream_memoization to make this boolean distinct from the state on the Callable itself?

Other than that, I'm happy to merge once the tests pass (ideally with some new unit tests!)

@@ -404,11 +443,11 @@ class PointerXY(LinkedStream):
the plot bounds, the position values are set to None.
"""

x = param.ClassSelector(class_=(Number, util.basestring), default=None,
x = param.ClassSelector(class_=(Number, util.basestring, tuple), default=None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change that snuck in. Allows the Pointer stream to work with nested categorical axes so worth keeping (and I can't be bothered to make a new PR).

@@ -101,7 +101,7 @@ def default(self, obj):
elif isinstance(obj, np.ndarray):
return obj.tolist()
if pd and isinstance(obj, (pd.Series, pd.DataFrame)):
return repr(sorted(list(obj.to_dict().items())))
return obj.to_csv().encode('utf-8')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fair bit faster, although still not great, hence also adding a hashkey.

@philippjfr
Copy link
Member Author

Ready to merge.

@jlstevens
Copy link
Contributor

Looks good. Merging.

@jlstevens jlstevens merged commit ad62108 into master Oct 23, 2017
@philippjfr philippjfr deleted the avoid_deep_hash branch October 28, 2017 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants