How python compares a float and an int objects?

Опубликовано: 05 Октябрь 2024
на канале: Arpit Bhayani
1,249
29

How python internally performs the comparison of a float and an integer value? We find this out in this video.


Comparing a float to an int is a fascinating problem, especially for Python. Comparing numbers involve comparing magnitudes across different types; plus things become even more complex considering Python supports infinitely long number.

Chapters:
0:00 Introduction to number comparison

1:14 Disassembling the code
2:00 Understanding COMPARE_OP
2:54 Exploring RichCompare
7:16 Understanding the core logic


The Honest Python

The Honest Python is a series in which we dissect certain features, behaviors, and not-so-obvious outputs by diving deeper into the CPython source code and if possible altering it to get a much clearer understanding.

Arpit's System Design Masterclass

I teach an 8-week cohort-based course on System Design - a masterclass that helps you become great at designing systems that are scalable, fault-tolerant, and highly available.

The program will have a blend of Live Classes happening on Weekends, 1:1 Mentorship sessions happening on weekdays, assignments and, group projects. The program is designed to be intense and crisp so as to accelerate the overall learning.

You can find more details about the program at https://arpitbhayani.me/masterclass

Subscribe to my free newsletter

🔥 Once a week, in your inbox, an essay about programming languages internals, or a deep dive on some super-clever algorithm, or just a few tips on building highly scalable distributed systems.

https://arpitbhayani.me/newsletter

If my work adds value, consider supporting me: https://www.buymeacoffee.com/arpitbha...

Follow me on other social platforms

Github: https://github.com/arpitbbhayani
LinkedIn:   / arpitbhayani  
Twitter:   / arpit_bhayani  

Stay Awesome,
Arpit