hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.31k stars 604 forks source link

Faster Message string representation #1858

Closed pierreluctg closed 2 months ago

pierreluctg commented 2 months ago

Improved the speed of data conversion to hex string. This also as a result improves the can.Printer logger performance.

Main Branch

$ python -m timeit -s "import can" "str(can.Message(data=(_ for _ in range(64))))"
20000 loops, best of 5: 14.7 usec per loop

This PR

$ python -m timeit -s "import can" "str(can.Message(data=(_ for _ in range(64))))"
100000 loops, best of 5: 3.47 usec per loop