[Git][NTPsec/ntpsec][master] 2 commits: Performance-tweak against pylib/poly.py

Gary E. Miller (@garyedmundsmiller) gitlab at mg.gitlab.com
Mon Nov 25 03:08:40 UTC 2024



Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
8be3f32d by Folkert van Heusden at 2024-11-25T03:05:29+00:00
Performance-tweak against pylib/poly.py

"polyord()" is now 4.4% faster on python 3.12.7 and 3.7% faster on
python 3.13.0.

- - - - -
1a4c1484 by Folkert van Heusden at 2024-11-25T03:05:29+00:00
With python 3.12.7, this patch gives a 4.4% speed improvement.
With python 3.13.0 it is 3.7%.

- - - - -


1 changed file:

- pylib/poly.py


Changes:

=====================================
pylib/poly.py
=====================================
@@ -74,16 +74,16 @@ else:  # Python 3
 
     def polyord(c):
         "Polymorphic ord() function"
-        if isinstance(c, str):
+        try:
             return ord(c)
-        else:
+        except TypeError as te:
             return c
 
     def polychr(c):
         "Polymorphic chr() function"
-        if isinstance(c, int):
+        try:
             return chr(c)
-        else:
+        except TypeError as te:
             return c
 
     def string_escape(s):



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/5cffe91b8ba66742263316bd9e034b73e900fd3c...1a4c1484f7653ca5d2af7299f5bf8e8dd9dbf48c

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/5cffe91b8ba66742263316bd9e034b73e900fd3c...1a4c1484f7653ca5d2af7299f5bf8e8dd9dbf48c
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20241125/95177f8c/attachment-0001.htm>


More information about the vc mailing list