Chained Comparison Operators in Python

Arpit Bhayani (~arpit71)


We explore the internals of Python and answer

  • how Chained Comparison Operators are evaluated
  • how Python implements short-circuit evaluations

On top of that, we alter the evaluation strategy and make it more C-like.

Here's the outline:

  • Chained Comparison Operators
  • How Python and C differ in evaluation
  • Disassembling and walkthrough
  • Short-circuit evaluation
  • Tracing the CPython code
  • How python evaluates
  • Altering to make it a C-like
  • Disassembling and walkthrough again


Basic working knowledge of Python would be good to have.

Video URL:

Content URLs:

Here's me explaining this:

A detailed writeup about this:

Speaker Info:

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 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.

Speaker Links:


Essays and Blogs:

YouTube Channel:

LinkedIn Profile:

Section: Core Python
Type: Talks
Target Audience: Intermediate
Last Updated: