8000 accelerate plotly JSON encoder for numpy arrays without nans by emmanuelle · Pull Request #2880 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content

accelerate plotly JSON encoder for numpy arrays without nans #2880

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

Merged
merged 10 commits into from
Nov 17, 2020
Prev Previous commit
Next Next commit
black
  • Loading branch information
emmanuelle committed Nov 13, 2020
commit 627c00fd4d935070321aa1e6304c572c95b59eab
2 changes: 1 addition & 1 deletion packages/python/plotly/_plotly_utils/utils.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def encode(self, o):
# We catch false positive cases (e.g. strings such as titles, labels etc.)
# but this is ok since the intention is to skip the decoding / reencoding
# step when it's completely safe
if not ('Infinity' in encoded_o or 'NaN' in encoded_o):
if not ("Infinity" in encoded_o or "NaN" in encoded_o):
return encoded_o
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this for now given your description of the performance characteristics.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe check for NaN first, as it feels like that'd appear more frequently?

# now:
# 1. `loads` to switch Infinity, -Infinity, NaN to None
Expand Down
0