openpyxl read/write is slow compared to cpython
Greetings. Unsure if this issue should be raised here, or directly with openpyxl. Please advise.
- Reading and writing
xlsxusing pypy/openpyxl is slow compared with cpython
Issue Example - how to recreate
The example just demonstrates the observed problem and isn't actually being used.
Given some workbook (Unfortunately, I was prevented from inserting a demo file, but any excel file you have should recreate the issue. I just made a simple random 5x50 matrix), I simply load and save the workbooks (in a jupyter notebook).
from openpyxl import workbook, load_workbook def load(): return load_workbook("some_spreadsheet_with_values.xlsx") workbook_ = load() def save(workbook_): workbook_.save("new_file.xlsx") %timeit load() %timeit save(workbook_)
I find the following performance estimates (for my demo spreadsheet noted above)
load- 33.9 ms ± 2.31 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
save- 323 ms ± 79.8 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
load- 8.64 ms ± 45.1 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
save- 9.46 ms ± 1.48 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)
- Would you be able to explain the reason for this notable difference between pypy and cpython?
- Is there a more appropriate way to load/save excel workbooks using pypy/openpyxl?