Skip to content
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

Improve performance for large files #56

Merged
merged 1 commit into from
Mar 27, 2014

Conversation

HansWeltar
Copy link

xmltodict becomes slow when you have an XML file with large texts.
Enabling the parser.buffer_text option dramatically increases performance.
Benchmark below. Unittests still work.

Code used to benchmark:

import xmltodict
import time
xml = "<root>" + ("a"*70+"\n")*10000 + "</root>"
s=time.time()
x=xmltodict.parse(xml)
print(time.time() - s)

#19.9860811234 seconds without buffer_text
#0.059289932251 seconds with buffer_text

So 300 times faster

xmltodict becomes slow when you have an XML file with large texts.
Enabling the parser.buffer_text option dramatically increases performance.

Code used to benchmark:

import xmltodict
import time
xml = "<root>" + ("a"*70+"\n")*10000 + "</root>"
s=time.time()
x=xmltodict.parse(xml)
print(time.time() - s)

 # 19.9860811234 seconds without buffer_text
 # 0.059289932251 seconds with buffer_text
 # So 300 times faster
@martinblech
Copy link
Owner

That's awesome, thank you for this contribution!

martinblech added a commit that referenced this pull request Mar 27, 2014
Improve performance for large files
@martinblech martinblech merged commit 861e50c into martinblech:master Mar 27, 2014
markjdb pushed a commit to markjdb/freebsd-ports that referenced this pull request Apr 12, 2014
- Add TEST_DEPENDS in preparation of automatic test infrastructure

Changelog:
* Improve performance for large files [1]

[1] martinblech/xmltodict#56

PR:           188252
Submitted by: myself
Approved by:  koobs@ (mentor)
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

Successfully merging this pull request may close these issues.

2 participants