Skip to content

Speed up generation of large QR Codes

What does the merge request do?

For TestLargeQRCodes, qr code generation time is reduced from 7.5s to 1.3s on my machine (the unit test still takes about 3s, which is due to XML comparison). The improvement is less prominent for smaller qr codes, but they are also generated approx. 2 times faster.

Implementation notes

This is done through elimination of redundant computations (the computation of the lookup table was duplicated, this was replaced by ring_iterator) and use of numpy arrays where useful. The remaining runtime is scattered across the code, I didn't find any additional obvious hot paths (the mix of very small and very large functions makes cProfiling this a bit difficult), the runtime seems reasonable now.

Summary for release notes

QR Codes are generated between 2 and 5 times faster, depending on the size of the QR code.

Checklist

  • Add unit tests (if applicable)
  • Changes to inkex/ are well documented
  • Clean merge request history

Merge request reports