TLDR: Python Internals - I Made Addition Unpredictable
Date: 2020-01-03 Source: https://arpitbhayani.me/blogs/i-changed-my-python
Overview
Explore Python internals by tweaking its source code! Learn how I made addition unpredictable and the challenges I faced. For checking if both the operands for BINARY_ADD operation are numbers I used the predefined function named PyNumber_Check which checks if object referenced by PyObject is number or not.
Key Points
- Checking if operands are numbers: For checking if both the operands for BINARY_ADD operation are numbers I used the predefined function named PyNumber_Check which checks if object referenced by PyObject is number or not.
- Did you ever take a peek at Python’s source code?
- I didn’t and hence I decided to have some fun with it this week.
- After cloning the repository I realized how well written is the code that makes python what it is.
- In the process of exploring the codebase, I thought of making some changes, not big optimizations but some minor tweaks that will help me understand how Python is implemented in C and along the course learn some internals.