You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sanitize_doc was a bottleneck for mongo inserting. sanitize_np fixes this problem. I made it a separate function because sanitize_doc also changes tuples to lists in addition to sanitizing numpy, and this feature is useful for some tests.
We encountered that in the wild at some point and that was our reason for switching to the approach currently used in sanitize_doc. Would be nice to have something that can handle that but is fast, which a round-trip through JSON is not.
It would be better to duck-type if we can. Resorting to isinstance creates fragility because it won't work on things are dict-like or list-like. For example, this won't recurse into tuples. See for example https://github.com/NSLS-II/databroker/blob/30e9c707171df5ad14cd58a21382284af7c7db87/databroker/utils.py#L29-L42 where we sniffed out dicts based on the existence of an .items() attribute. A good trick for catching lists/tuples/etc. is to use isinstance(x, collections.abc.Iterable).
The reason will be displayed to describe this comment to others. Learn more.
Unreachable line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sanitize_doc was a bottleneck for mongo inserting. sanitize_np fixes this problem. I made it a separate function because sanitize_doc also changes tuples to lists in addition to sanitizing numpy, and this feature is useful for some tests.