Making Python C-like
Arpit Bhayani (~arpit71) |
We explore the internals of Python and alter its evaluation strategy.
Chained comparison operators "a < b < c", in Python, are evaluated like they are evaluated in Mathematics. So doing "a < b < c" answers if
b likes between
c. In this talk I give a walkthrough on what it takes to alter this strategy and make it C-like.
Here's the outline:
- Introduction (2 minutes)
- Evaluation strategies Math-like and C-like (2 minutes)
- Disassembling and Execution Walkthrough (6 minutes)
- How Python's evaluation strategy is Math-like (2 minutes)
- What we need to make it C-like (4 minutes)
- Altering the source code (2 minutes)
- Disassembling and Execution Walkthrough (3 minutes)
- Takeaways and Conclusion (3 minutes)
- Questions (6 minutes)
Basic working knowledge of Python would be good to have.
Here's me explaining this: https://www.youtube.com/watch?v=zz2Lu5ht_jA
A detailed writeup about this: https://arpitbhayani.me/blogs/chained-operators-python
I tweak CPython for fun and try to understand how it works. I am working as Sr. Engineering Manager - SRE at Unacademy. Prior to this worked at Amazon and Practo. I run a CS Engineering focussed newsletter https://arpitbhayani.me/newsletter where I write and share an essay about programming languages internals, deep dives on some super-clever algorithms, and few tips on building scalable distributed systems. The newsletter currently has close to 1200+ subscribers.
Essays and Blogs: https://arpitbhayani.me/blogs
YouTube Channel: https://www.youtube.com/channel/UC_b1GUJv_2QiMP4BxC9-Dxg
LinkedIn Profile: https://www.linkedin.com/in/arpitbhayani/