I made a typo! In this example it should be === instead of == in the 
comment:

julia> is(x, y) # Same as: x === y
false

get() doesn't raise error, since it's safe to use with a default value, but 
this gives an error instead as you would expect:

julia> d[3]
ERROR: key not found: 3
 in getindex at dict.jl:509

julia> d[convert(Int64, 3)]
5


Also python seems to use equality instead of identity here:

[ismaelvc@toybox ~]$ python
Python 3.3.3 (default, Nov 26 2013, 13:47:45) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> d = dict()
>>> d[3] = 5
>>> d
{3: 5}

>>> d[3]
5
>>> d[3.0] # Python seems to use equality instead
5

>>> x, y = 5, 5.0

>>> type(x), type(y)
(<class 'int'>, <class 'float'>)

>>> x == y
True
>>> x is y # Same as is/=== in Julia in concept, but not implementation
False

>>> # Julia uses the bits representation but Python uses the memory adress 
to test identity:
>>> id(x), id(y) 
(3077911968, 3070758096)




Reply via email to