diff options
Diffstat (limited to 'slides.rst')
-rw-r--r-- | slides.rst | 64 |
1 files changed, 45 insertions, 19 deletions
@@ -5,6 +5,7 @@ Wounded hero revived Lessons learned from porting M2Crypto to Py3k :Author: Matěj Cepl <mcepl@cepl.eu> +:URL: https://matej.ceplovi.cz/clanky/PyCon18-m2crypto/slides.html Origins @@ -149,30 +150,13 @@ Strategy * Type Hints +* Documentation strings + * CI * Extension of platform support -Type Hints -========== - -* `PEP 484`_ providing **optional** type annotations. Quite - controversial, but clearly very useful for libraries - -* Native for Python >= 3.5, but supports py2k compatible syntax:: - - def sum(x, y): - # type: (int, int) -> int - return x + y - -* Especially useful for our situation: marking types helps us to - analyze what invidivual py2k ``str`` actually mean. - -.. _`PEP 484`: - https://www.python.org/dev/peps/pep-0484/ - - C API ===== @@ -205,3 +189,45 @@ C shims of missing functions - ``PyFile_AsFile()`` I have no idea, why it was removed from py3k API + + +Type Hints +========== + +* `PEP 484`_ providing **optional** type annotations. Quite + controversial, but clearly very useful for libraries + +* Native for Python >= 3.5, but supports py2k compatible syntax:: + + def sum(x, y): + # type: (int, int) -> int + return x + y + +* Especially useful for our situation: marking types helps us to + analyze what invidivual py2k ``str`` actually mean. + +.. _`PEP 484`: + https://www.python.org/dev/peps/pep-0484/ + + +Python porting (shims again) +============================ + +The same principles apply as with C functions, “shims, not +``#ifdef`` s”. + +* Plenty of issues are resolved by using ``six`` (or + ``modernize``, ``future``), so use them. If I did it again, + I would probably use ``future`` (and wrote py3k code), but the + difference is slim. + +* Do not hesitate to create your own shims. So I have for + example, ``bix_to_hex`` and ``oct_to_num`` or padding functions + there. + +* http://python-future.org/compatible_idioms.html + +.. class:: handout + + Whoever does not understand LISP, is doomed to reinvent it. + Badly. LISP -> six |