News for hackers. Stuff that matters.
Re:Why Python is Slow: Looking Under the Hood by yxhuvud on Saturday May 10, 2014 @03:28AM (#7724759)
The problem is that comparing by value is not a good default for ==. A language should strive to make the common tasks as simple as possible to do right, while not making it impossible to check object equality or some other kind of equality.

Compare Ruby:

  1 == 1 => true
  4711 == 4711 => true

  1.object_id == 1.object_id => true
  4711.object_id == 4711.object_id => false
Re:Why Python is Slow: Looking Under the Hood by koenigdavidmj on Saturday May 10, 2014 @03:34AM (#7724770)
The #equal? method does your object_id comparison, by the way.

Ruby's default #== for new classes simply performs identity comparison, just like in Java. The difference is that Ruby has operator overloading, so all the builtin classes overload it with something sensible.

(This could work in Java, or it could go the .NET route and ban using the == operator entirely until a certain interface (.NET's IEquatable) is fulfilled.)