DEV Community

Cover image for Don't Treat One Like Another
Naufan Rusyda Faikar
Naufan Rusyda Faikar

Posted on • Edited on

3 2

Don't Treat One Like Another

One day, someone has asked on Discord:

>>> import numpy as np
>>> my_list = [[1,2], [2,3], [3,4], [4,5]]
>>> [1,3] in my_list
False
>>> my_array = np.array(my_list)
>>> [1,3] in my_array
True
Enter fullscreen mode Exit fullscreen mode

Why numpy is doing so?

They are not the same as we already know. So, why do we expect them to behave the same? Every programming language, library, and whatsoever has its own implementation. True, it is all about different implementations, after all. We can even have this weirdo:

>>> a = 1
>>> b = 1
>>> a == b
True
>>> a is b
True
>>> a = 9999
>>> b = 9999
>>> a == b
True
>>> a is b
False
Enter fullscreen mode Exit fullscreen mode

See? So, it is not ever a good idea to treat anybody the same way, for you and I are unique~ Although, in some ways, we are still comparable.

By the way, if you are curious of the two, you can follow up by reading:

Take care!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay