Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Change: Use PyPy's StringBuilder to speed up the use of StringIO. #98
This is an alternative to #76 .
Inspiration was found from https://bitbucket.org/pypy/pypy/pull-requests/132/speed-up-pickledumps-fixes-issue-979/diff , where a similar fix was applied to speed up pickle.dumps for PyPy.
This only affects PyPy, normal CPython versions will still use
Some test results using this PR with PyPy 7.3.0 to compile Iron Horse nml
Python 3.8 timings are unchanged, as expected.
Much neater than my attempt!
That said, Ijust discovered that PyPy upstream have fixed this in 7.3.1:
(the changelog categories are confusing, but I've verified that the relevant commits appear in 7.3.1 and not 7.3.0).
That's done by internally using a StringBuffer somewhat like this approach...
Testing on Linux with pypy 7.3.1, there is no measurable difference in performance with this patch; the present code is as fast with 7.3.1 as the patched version in 7.3.0 and earlier.