Comment

Comment by gizmo

You can't actually override operator_plus in Python for numbers. Numbers in Python are magic for performance reasons. You can look at the Python bytecode to easily see this:

    def add_five(a):
        return a + 5
    dis.dis(add_five)
And this returns something like:

    LOAD FAST    a
    LOAD CONST   5
    BINARY ADD
    RETURN ACC
parent gizmo 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton