Skip to content

Printing json is very slow #729

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

Closed
hkarl opened this issue Feb 8, 2018 · 5 comments
Closed

Printing json is very slow #729

hkarl opened this issue Feb 8, 2018 · 5 comments

Comments

@hkarl
Copy link

hkarl commented Feb 8, 2018

Hi,

I just ran into the following hiccup: Printing json data can be VERY slow. It took about 45 seconds to print a json structure imported from a file about 1.2 Kbytes large (1239 bytes, to be precise). This is something that might deserve a warning, somehow?

Thanks a lot,

Holger

timeit.timeit('import json', number=3)
6.115995347499847e-06
timeit.timeit('import json; json.load(open("bla.json"))', number=3)
0.0003211210132576525
timeit.timeit('import json; print(json.load(open("bla.json")))', number=3)
{'metadata': {'kernelspec': {'language': 'c', 'name': 'c', 'display_name': 'C'}, 'language_info': {'file_extension': '.
c', 'name': 'c', 'mimetype': 'text/plain'}, 'celltoolbar': 'Create Assignment'}, 'nbformat_minor': 2, 'cells': [{'metad
ata': {'nbgrader': {'schema_version': 1, 'grade_id': 'cell-fbe773322fcd8530', 'grade': True, 'locked': False, 'points':
0, 'solution': True}}, 'cell_type': 'markdown', 'source': ['12345 2365 8899']}, {'metadata': {}, 'cell_type': 'markdow
n', 'source': ['# Test for a C -based assignment ']}, {'execution_count': None, 'metadata': {'nbgrader': {'schema_versi
on': 1, 'locked': False, 'grade_id': 'cell-472e432b19c0c2ae', 'grade': False, 'solution': True}}, 'source': ['#include
<stdio.h>\n', '\n', 'int main() {\n', ' // BEGIN SOLUTION\n', ' printf("hallo\n");\n', ' // END SOLUTION\n',
'}'], 'cell_type': 'code', 'outputs': []}, {'execution_count': None, 'metadata': {}, 'source': [], 'cell_type': 'code',
'outputs': []}], 'nbformat': 4}
{'metadata': {'kernelspec': {'language': 'c', 'name': 'c', 'display_name': 'C'}, 'language_info': {'file_extension': '.
c', 'name': 'c', 'mimetype': 'text/plain'}, 'celltoolbar': 'Create Assignment'}, 'nbformat_minor': 2, 'cells': [{'metad
ata': {'nbgrader': {'schema_version': 1, 'grade_id': 'cell-fbe773322fcd8530', 'grade': True, 'locked': False, 'points':
0, 'solution': True}}, 'cell_type': 'markdown', 'source': ['12345 2365 8899']}, {'metadata': {}, 'cell_type': 'markdow
n', 'source': ['# Test for a C -based assignment ']}, {'execution_count': None, 'metadata': {'nbgrader': {'schema_versi
on': 1, 'locked': False, 'grade_id': 'cell-472e432b19c0c2ae', 'grade': False, 'solution': True}}, 'source': ['#include
<stdio.h>\n', '\n', 'int main() {\n', ' // BEGIN SOLUTION\n', ' printf("hallo\n");\n', ' // END SOLUTION\n',
'}'], 'cell_type': 'code', 'outputs': []}, {'execution_count': None, 'metadata': {}, 'source': [], 'cell_type': 'code',
'outputs': []}], 'nbformat': 4}
{'metadata': {'kernelspec': {'language': 'c', 'name': 'c', 'display_name': 'C'}, 'language_info': {'file_extension': '.
c', 'name': 'c', 'mimetype': 'text/plain'}, 'celltoolbar': 'Create Assignment'}, 'nbformat_minor': 2, 'cells': [{'metad
ata': {'nbgrader': {'schema_version': 1, 'grade_id': 'cell-fbe773322fcd8530', 'grade': True, 'locked': False, 'points':
0, 'solution': True}}, 'cell_type': 'markdown', 'source': ['12345 2365 8899']}, {'metadata': {}, 'cell_type': 'markdow
n', 'source': ['# Test for a C -based assignment ']}, {'execution_count': None, 'metadata': {'nbgrader': {'schema_versi
on': 1, 'locked': False, 'grade_id': 'cell-472e432b19c0c2ae', 'grade': False, 'solution': True}}, 'source': ['#include
<stdio.h>\n', '\n', 'int main() {\n', ' // BEGIN SOLUTION\n', ' printf("hallo\n");\n', ' // END SOLUTION\n',
'}'], 'cell_type': 'code', 'outputs': []}, {'execution_count': None, 'metadata': {}, 'source': [], 'cell_type': 'code',
'outputs': []}], 'nbformat': 4}
47.67986440501409

@thomasballinger
Copy link
Member

Thanks hcarl, this is some https://accidentallyquadratic.tumblr.com/ behavior in curtsies that just started being exercised.

@thomasballinger
Copy link
Member

See #703 for more

@hkarl
Copy link
Author

hkarl commented Feb 12, 2018

Interesting thanks - probably makes sense to close this one, then. Sorry for not detecting the other issue.

@hkarl hkarl closed this as completed Feb 12, 2018
@ikanobori
Copy link
Contributor

I have reverted the change that caused this, if you upgrade to 0.17.1 you should be ok again :)

@hkarl
Copy link
Author

hkarl commented Feb 13, 2018

Wonderful, looks great! Thanks a lot!

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

No branches or pull requests

3 participants