16 == [16]
true in js
false in python 16 == [16]
true in js
false in python >>> a = 5
>>> b = 5
>>> a is b
True
>>> a = -4
>>> b = -4
>>> a is b
True
>>> a = 300
>>> b = 300
>>> a is b
False
Every language has these, JS a bit more (because mostly impossible to fix thanks to backward compatibility). I don't understand why you would do that anyway.Most linters would display errors even if you did (in both languages).
The is operator checks to see if both point to the same area in memory. Small numbers are preallocated in python so they point to the same memory.
>>>a=300
>>>b=a
>>>a is b
True
The point was that both languages have pitfalls.
It is a pitfall. It's not about what python developers think about it. It is about what people from other languages experience when they learn the language.
(Though it's not my main point, I want to add as (also) a python developer, that I think this is a terrible design choice, which could easily be avoided. In this case python doesn't "threat everything as object" it treats small int literals differently than bigger int literals)
Regardless, if, as you said, the operational semantics of the language is inconsistent among implementations and depends on internal caching, it only makes it worse.
false