question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

json data loading is very slow on larger objects

See original GitHub issue

Using json.loads() on larger objects (not very large, it’s enough to be aprox. 1 kB) is very slow. Looks like json module is using re, which causes this problem.

Trying to switch json to use _jsre, but this implementation is not working. json library is using match().end(), which returns different results for re and _jsre. Example:

>>> import re
>>> re.compile(" *").match("   test").end()
3
>>> import _jsre
>>> _jsre.compile(" *").match("   test").end()
1

Is it possible to fix this? Is _jsre still supported? Or is it possible to use process json differently? Also have no luck to use window.JSON.parse(), whcih returns hard to use JS objects.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
PierreQuentelcommented, Nov 28, 2019

Javascripts objects such as JSON are intended to be used through the javascript module, which adds a layer to make them usable with Brython :

from javascript import JSON

t = JSON.parse('{"data": [{"grp": 2}]}')
print(t) # prints "{'data': [{'grp': 2}]}"

They are also available as attributes of window (because the window object in Javascript mixes everything from the Web API to language-specific names), but I will add a deprecation message suggesting to use the javascript module instead.

0reactions
ondrejjcommented, Nov 30, 2019

May be an switch will be useful. Something like from future import …, just different names. Something what switches json.parse and other function to not fully compatible, but very fast mode. from brython import browser_json ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to manage a large JSON file efficiently and quickly - Sease
In this blog post, I want to give you some tips and tricks to find efficient ways to read and parse a big...
Read more >
JSON.stringify is very slow for large objects - Stack Overflow
I have a very big object in javascript (about 10MB). And when I stringify it, it takes a long time, so I send...
Read more >
Processing large JSON files in Python without running out of ...
Loading complete JSON files into Python can use too much memory, leading to slowness or crashes. The solution: process JSON data one chunk ......
Read more >
11 Ways to Improve JSON Performance & Usage - Stackify
1. You may need multiple JSON libraries for optimal performance and features · 2. Use streams whenever possible · 3. Compress your JSON...
Read more >
Slow performance loading igGrid with large json data set
Hello,. I have a data set of 25,000 rows, 12 columns and for the table to load onto the page it takes about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found