Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
heuer committed Jun 25, 2019
2 parents 64d912a + 128d18f commit 3cc2644
Show file tree
Hide file tree
Showing 18 changed files with 365 additions and 232 deletions.
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changes
=======

0.3.0 -- 2019-06-25
-------------------
* Performance improvements (evaluation of mask scores)
* Faster PNG output
* Faster ``utils.matrix_iter`` (which improves several writers, i.e. PNG)
* Deprecation of ``encoder.score_n1``, ``encoder.score_n2``, ``encoder.score_n3``,
and ``encoder.score_n4``.
Use ``encoder.mask_scores`` or ``encoder.evaluate_mask``.


0.2.9 -- 2019-04-24
-------------------
* Fixed typos
Expand Down
4 changes: 0 additions & 4 deletions docs/_static/chart_create.svg

This file was deleted.

6 changes: 3 additions & 3 deletions docs/_static/chart_png.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/_static/chart_svg.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions docs/comparison-qrcode-libs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Performance
-----------

Some performance indicators. The script `benchmarks.py`_ ran on a
Mac Mini 2,26 Core2 Duo using CPython 2.7.14. Each SVG / PNG image uses a
Mac Mini 2,26 Core2 Duo using CPython 2.7.15. Each SVG / PNG image uses a
scaling factor of 10 (aside from qrcodegen which does not support any scaling).


Expand All @@ -67,10 +67,16 @@ Create a QR Code

Create a 1-M QR Code "QR Code Symbol".

.. image:: _static/chart_create.svg
.. image:: _static/chart_create_1m.svg
:alt: Chart showing the results of creating a 1-M QR Code.


Create a 30-H QR Code "QR Code Symbol".

.. image:: _static/chart_create_30h.svg
:alt: Chart showing the results of creating a 30-H QR Code.


Create a QR Code and serialize it as SVG
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
38 changes: 31 additions & 7 deletions sandbox/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import segno
try:
import qrcode
from qrcode import QRCode, ERROR_CORRECT_M
from qrcode import QRCode, ERROR_CORRECT_M, ERROR_CORRECT_L, ERROR_CORRECT_H
from qrcode.image.svg import SvgImage, SvgPathImage
except ImportError:
QRCode = None
Expand All @@ -24,11 +24,17 @@

if QRCode:
def create_qrcode(data='QR Code Symbol'):
"""qrcode create"""
"""qrcode create 1-M"""
qr = QRCode(error_correction=ERROR_CORRECT_M)
qr.add_data(data, optimize=False)
qr.make()

def createbig_qrcode(data='QR Code Symbol'):
"""qrcode create 30-H"""
qr = QRCode(error_correction=ERROR_CORRECT_H, version=30)
qr.add_data(data, optimize=False)
qr.make()

def svg_qrcode_path(data='QR Code Symbol'):
"""qrcode SVG path"""
qr = QRCode(error_correction=ERROR_CORRECT_M, box_size=10,
Expand All @@ -52,9 +58,13 @@ def png_qrcode(data='QR Code Symbol'):

if pyqrcode:
def create_pyqrcode(data='QR Code Symbol'):
"""PyQRCode create"""
"""PyQRCode create 1-M"""
pyqrcode.create(data, error='m')

def createbig_pyqrcode(data='QR Code Symbol'):
"""PyQRCode create 30-H"""
pyqrcode.create(data, error='h', version=30)

def svg_pyqrcode(data='QR Code Symbol'):
"""PyQRCode SVG"""
pyqrcode.create(data, error='m').svg('out/pyqrcode_%s.svg' % data, scale=10)
Expand All @@ -66,7 +76,7 @@ def png_pyqrcode(data='QR Code Symbol'):

if QrCode:
def create_qrcodegen(data='QR Code Symbol'):
"""qrcodegen create"""
"""qrcodegen create 1-M"""
QrCode.encode_text(data, QrCode.Ecc.MEDIUM)

def svg_qrcodegen(data='QR Code Symbol'):
Expand All @@ -76,8 +86,13 @@ def svg_qrcodegen(data='QR Code Symbol'):


def create_segno(data='QR Code Symbol'):
"""Segno create"""
segno.make_qr(data, error='m')
"""Segno create 1-M"""
segno.make_qr(data, error='m', boost_error=False)


def createbig_segno(data='QR Code Symbol'):
"""Segno create 30-H"""
segno.make_qr(data, error='h', version=30, boost_error=False)


def svg_segno(data='QR Code Symbol'):
Expand All @@ -98,6 +113,14 @@ def run_create_tests(which=None, number=200, table=None):
_run_tests(tests, number, table)


def run_createbig_tests(which=None, number=200, table=None):
tests = ('createbig_pyqrcode',
'createbig_qrcode', 'createbig_segno',)
if which:
tests = filter(lambda n: n[len('createbig_'):] in which, tests)
_run_tests(tests, number, table)


def run_svg_tests(which=None, number=200, table=None):
tests = ('svg_pyqrcode', 'svg_qrcodegen',
'svg_qrcode_path', 'svg_qrcode_rects', 'svg_segno',)
Expand Down Expand Up @@ -136,8 +159,9 @@ def _run_tests(tests, number, table=None):
import csv
table = []
run_create_tests(table=table)
run_createbig_tests(table=table)
run_svg_tests(table=table)
run_png_tests(table=table)
with open('out/results.csv', 'wb') as f:
with open('out/results.csv', 'w') as f:
writer = csv.writer(f)
writer.writerows(table)
12 changes: 8 additions & 4 deletions sandbox/make_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,24 @@ def create_charts():
'qrcodegen': '#009688',
'Segno': '#FFC107',
}
create_data = []
create_1m_data = []
create_30h_data = []
svg_data = []
png_data = []
with open('out/results.csv') as f:
reader = csv.reader(f)
for row in reader:
name, val = row
if name.endswith(' create'):
create_data.append((name.replace(' create', ''), val))
if name.endswith(' create 1-M'):
create_1m_data.append((name.replace(' create 1-M', ''), val))
elif name.endswith(' create 30-H'):
create_30h_data.append((name.replace(' create 30-H', ''), val))
elif name.endswith(' PNG'):
png_data.append((name.replace(' PNG', ''), val))
elif ' SVG' in name:
svg_data.append((name.replace(' SVG', ''), val))
for data, title, filename in ((create_data, 'Create a 1-M QR Code', 'out/chart_create.svg'),
for data, title, filename in ((create_1m_data, 'Create a 1-M QR Code', 'out/chart_create_1m.svg'),
(create_30h_data, 'Create a 30-H QR Code', 'out/chart_create_30h.svg'),
(svg_data, 'Create a 1-M QR Code and write SVG', 'out/chart_svg.svg'),
(png_data, 'Create a 1-M QR Code and write PNG', 'out/chart_png.svg')):
create_chart(title,
Expand Down
4 changes: 0 additions & 4 deletions sandbox/out/chart_create.svg

This file was deleted.

4 changes: 4 additions & 0 deletions sandbox/out/chart_create_1m.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions sandbox/out/chart_create_30h.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions sandbox/out/chart_png.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions sandbox/out/chart_svg.svg

This file was deleted.

27 changes: 15 additions & 12 deletions sandbox/out/results.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
PyQRCode create,28.89
qrcodegen create,16.72
qrcode create,12.44
Segno create,13.14
PyQRCode SVG,35.06
qrcodegen SVG,18.51
qrcode SVG path,61.90
qrcode SVG rects,55.35
Segno SVG,15.85
PyQRCode PNG,120.46
qrcode PNG,17.84
Segno PNG,19.80
PyQRCode create 1-M,28.63
qrcodegen create 1-M,15.79
qrcode create 1-M,11.70
Segno create 1-M,8.30
PyQRCode create 30-H,1269.05
qrcode create 30-H,491.72
Segno create 30-H,331.68
PyQRCode SVG,30.80
qrcodegen SVG,17.68
qrcode SVG path,57.80
qrcode SVG rects,55.18
Segno SVG,9.71
PyQRCode PNG,117.89
qrcode PNG,17.24
Segno PNG,13.51
2 changes: 1 addition & 1 deletion segno/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
except NameError: # pragma: no cover
str_type = str

__version__ = '0.2.9'
__version__ = '0.3.0'

__all__ = ('make', 'make_qr', 'make_micro', 'make_sequence', 'QRCode',
'QRCodeSequence', 'QRCodeError', 'ErrorLevelError', 'ModeError',
Expand Down

0 comments on commit 3cc2644

Please sign in to comment.