cython
play

Cython Stefan Behnel <stefan_ml@behnel.de> EuroPython, Basel, - PowerPoint PPT Presentation

Cython Stefan Behnel <stefan_ml@behnel.de> EuroPython, Basel, July 2019 Hi! Stefan Behnel Sofuware/Data Engineer & Trainer use Python since 2002 CPython core dev since 2019 Cython dev core dev since 2007


  1. Cython Stefan Behnel <stefan_ml@behnel.de> EuroPython, Basel, July 2019

  2. Hi! ● Stefan Behnel ● Sofuware/Data Engineer & Trainer ● use Python since 2002 – CPython core dev since 2019 ● Cython dev – core dev since 2007 – training and consultjng (also in-house) ● work for TrustYou since 2017 2

  3. TrustYou ● Terabytes of hotel guest reviews – non-literate brain dumps, 24 languages, collected from all over the Internet, surveys, portals, partners, … ● Text and data analysis – sentjment, categorisatjon, trends, tops/fmops… ● Sell informatjon – tell hotels what to improve – tell chains how their brands or branches compare – tell portals which hotels to recommend 3

  4. TrustYou Meta-Review → https://trustyou.com

  5. Some T ools we use at TrustYou ● NumPy ● SciPy ● Scikit-learn ● Pandas ● nltk ● spaCy ● lxml ● PyYAML ● Hadoop/PySpark ● ... 5

  6. Some T ools we use at TrustYou ● NumPy ● SciPy ● Scikit-learn ● Pandas ● ( nltk ) ● spaCy ● lxml ● PyYAML ● Hadoop/PySpark ● ... 6

  7. H5PY X k r o w t e N

  8. H5PY X k r o w t e N

  9. What is Cython used for? 1) Integrate natjve code with Python 2) Speed up Python code in CPython 3) Write C without having to write C “We write C so you don‘t have to” 10

  10. Gradual T yping in Python 11

  11. Gradual T yping in Python statjc typing == fast & cumbersome dynamic typing == easy & slowish 12

  12. Gradual T yping in Python statjc typing == fast & cumbersome ↕ gradual typing ↕ dynamic typing == easy & slowish 13

  13. Gradual T yping ● Term coined 2006 by Siek & Taha – Blog post by Jeremy Siek (Univ. of Indiana/USA): htups:/ /wphomes.soic.indiana.edu/jsiek/what-is-gradual-typing/ – Basis for Python’s PEP-484 type annotatjons ● Best mix of statjc + dynamic typing – dynamic typing for ease of development – optjonal statjc typing for safety, speed, documentatjon ● Use statjc types only where they help – don’t require them where they get in the way 14

  14. Don’t type all your things! int 15

  15. What is Cython? ● Pragmatjc programming language – “Gradual Typing for Python” ● Optjmising compiler – Productjon proven – Widely used ● All about «gettjng things done» – Keeps focus on functjonality, not boilerplate – Allows moving freely between Python and C/C++ – As pythonic as you want, as low-level as you need 16

  16. Demo 17

  17. What’s new in Cython 3.0 ? It’s Python 18

  18. What’s new in Cython 3.0 ? It’s Python 3 19

  19. What’s new in Cython 3.0 ? It’s Python 3 … by default 20

  20. What’s new in Cython 3.0 ? ● Python 3 by default – language level “3str” ● Python def-functjon compatjbility – “binding” by default ● Binary special methods like Python (?) ● Positjonal-only arguments (PEP 570) ● Annotatjons as strings (PEP 563) (?) htups:/ /github.com/cython/cython/milestone/58 21

  21. Thanks! Any questjons? You can fjnd me at: Stefan.behnel@trustyou.com more info: www.trustyou.com 22

Recommend


More recommend