Title: ENH: Optional dependencies for accelerating JSON serialization · Issue #2944 · plotly/plotly.py · GitHub
Open Graph Title: ENH: Optional dependencies for accelerating JSON serialization · Issue #2944 · plotly/plotly.py
X Title: ENH: Optional dependencies for accelerating JSON serialization · Issue #2944 · plotly/plotly.py
Description: On top of #2943, I investigated a couple of interesting libraries we could potentially use as optional dependencies to further accelerate JSON serialization pybase64 I played with pybase64 a little, and it looks like an easy way to get a...
Open Graph Description: On top of #2943, I investigated a couple of interesting libraries we could potentially use as optional dependencies to further accelerate JSON serialization pybase64 I played with pybase64 a little...
X Description: On top of #2943, I investigated a couple of interesting libraries we could potentially use as optional dependencies to further accelerate JSON serialization pybase64 I played with pybase64 a little...
Opengraph URL: https://github.com/plotly/plotly.py/issues/2944
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ENH: Optional dependencies for accelerating JSON serialization ","articleBody":"On top of https://github.com/plotly/plotly.py/pull/2943, I investigated a couple of interesting libraries we could potentially use as optional dependencies to further accelerate JSON serialization\r\n\r\n## pybase64\r\nI played with [`pybase64`](https://pybase64.readthedocs.io/en/v0.2.0/) a little, and it looks like an easy way to get a decent speedup over the built-in python `base64` module for performing the numpy base64 encoding step being introduced in https://github.com/plotly/plotly.py/pull/2943. This wouldn't require any refactoring or anything, and can drop the base64 encoding time (which is a substantial portion of the total json encoding time for figures that contain large numpy arrays) by something liek 20% to 40%.\r\n\r\n## orjson\r\n[`orjson`](https://github.com/ijl/orjson) is a really impressive alternative JSON encoder that, in playing with a little bit, I've seen it be 2x to 5x times faster than the built-in Python `json` encoder.\r\n\r\n`orjson` doesn't support custom JSON encoder classes (like `PlotlyJSONEncoder`), so supporting this as an optional dependency would require a total refactor of the current json encoding process.\r\n\r\nBasically, we would need to switch to an architecture where we would preprocess the figure dictionary recursively to perform any conversions we need, and then feed that dictionary through the JSON encoder.\r\n\r\nAnother nice thing about `orjson` is that it automatically converts `nan` and `infinity` values to JSON `null` values, so the JSON re-endcoding stuff we were working through in https://github.com/plotly/plotly.py/pull/2880 wouldn't be needed (cc @emmanuelle ).\r\n\r\n\r\n","author":{"url":"https://github.com/jonmmease","@type":"Person","name":"jonmmease"},"datePublished":"2020-11-29T18:34:24Z","url":"https://github.com/plotly/plotly.py/issues/2944"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f1586fd7-c3d3-b12c-bd98-0f005cefe87f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B476:ADA9D:18F7934:2014B42:6B0135CC |
| html-safe-nonce | 7f8fa633bb11deafd564497c23395e60e856e71916156a3be223a5026c938076 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDc2OkFEQTlEOjE4Rjc5MzQ6MjAxNEI0Mjo2QjAxMzVDQyIsInZpc2l0b3JfaWQiOiI4OTg4MDc0MTk2NjYzODc1MDIwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3c08658eae11ba8f114d13a19fee25f150cf7207c906c42190641081edca29c4 |
| hovercard-subject-tag | issue:752977836 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.py/2944/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cc53cfdb0411201bcee9ceb9e8beabc7472c8bd956ed18b5fab5784b54498cc7/plotly/plotly.py/issues/2944 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cc53cfdb0411201bcee9ceb9e8beabc7472c8bd956ed18b5fab5784b54498cc7/plotly/plotly.py/issues/2944 |
| og:image:alt | On top of #2943, I investigated a couple of interesting libraries we could potentially use as optional dependencies to further accelerate JSON serialization pybase64 I played with pybase64 a little... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonmmease |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.py git https://github.com/plotly/plotly.py.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579099 |
| octolytics-dimension-repository_nwo | plotly/plotly.py |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579099 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.py |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width