Yes, we can. But don't do this at home. Seriously, the 1 object is used in many places and I have no clue what this might break and what that might do to your computer. I reject all responsibility. But I found it interesting to learn about these things.
Try it online!. I tried it there because such sites have got to be protected from our hacking anyway.
More explanation / analysis:
The memmove copied the value from the 2 object into the 1 object. Their size is 28 bytes each, but I skipped the first 24 bytes, because that's the object's reference count, type address, and value size, as we can view/verify as well:
reference count: 135 138
type address: 140259718753696 140259718753696
number of digits: 1 1
lowest digit: 1 1
The reference count gets increased by the getrefcount call, but I don't know why by 3. Anyway, ~134 things other than us reference the 1 object, and we're potentially messing all of them up, so... really don't try this at home.
The "digits" refer to how CPython stores ints as digits in base 230. For example, x = 2 ** 3000 has 101 such digits. Output for x = 123 ** 456 for a better test:
reference count: 1 2
type address: 140078560107936 140078560107936
number of digits: 106 106
lowest digit: 970169057 970169057
If you'd prefer not to mess with the actual contents of cached int or bool objects, you can fake making 1 == 2 like so:
>>> import builtins
>>> import sys
>>>
>>> def displayhook(value):
... if value is False:
... value = True
... elif value is 1:
... value = 2
... text = repr(value)
... sys.stdout.write(text)
... sys.stdout.write('\n')
... builtins._ = value
...
<stdin>:4: SyntaxWarning: "is" with a literal. Did you mean "=="?
>>> sys.displayhook = displayhook
>>> 1
2
>>> 1 == 2
True