Closed Hadatko closed 2 years ago
Hi @Hadatko
I've run some benchmark tests against your PR, results as follows:
Operating system: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 Python version: 3.10.0 pyubx2 version: 1.1.3 (CURRENT VERSION) Test cycles: 10,000
Executing benchmark test...
Benchmark test completed.
350,000 messages processed in 22.972 seconds = 15,235.67 txns/second.
Operating system: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 Python version: 3.10.0 pyubx2 version: 1.1.5 (YOUR DICT SWAP PR VERSION) Test cycles: 10,000
Executing benchmark test...
Benchmark test completed.
350,000 messages processed in 23.329 seconds = 15,002.94 txns/second.
I ran this a few times but could find no meaningful different in performance - if anything, your version is very slightly slower.
So, sorry, but I'm going to drop this one for now.
But do please keep the contributions coming. Many thanks.
Get rid of construction to going trough dict values to find key.
Signed-off-by: Cervenka Dusan cervenka@acrios.com
pyubx2 Pull Request Template
Description
Hello, i was curious about your opinion on this update. Same as you are doing in your code, sometimes i need find dict key using dict value. I didn't know about function key_from_val but anyway i don't really like it as you are iterating trough dict.items() often (every call in my case)... I think this can be faster and simpler solution. Downside is more memory to use (as new dictionaries are created)
Fixes # (issue)
Testing
Please test all changes, however trivial, against the supplied unittest suite
tests/test_*.py
e.g. by executing thetests/testsuite.py
module or using your IDE's native Python unittest integration facilities. Please describe any test cases you have amended or added to this suite to maintain >= 99% code coverage.Checklist:
CONTRIBUTING.MD
).tests/test_*.py
unittest suite to maintain >= 99% code coverage.tests/test_*.py
unittest suite.