News for hackers. Stuff that matters.
Re:What the Fuck Python by heavenlyblue on Saturday July 19, 2025 @04:12PM (#44618937)
Given that it starts with a thing called "id" which is an implementation detail and probably should not be used for equality, it seems like this is a geniuinely well designed language :)
Re:What the Fuck Python by mirashii on Saturday July 19, 2025 @04:15PM (#44618960)
id is not an implementation detail, it's a core built-in function of the language. The value that it returns is an implementation detail, but the properties of the value it returns are not and perfectly valid to rely on.
Re:What the Fuck Python by 0xDEAFBEAD on Sunday July 20, 2025 @03:08AM (#44622668)
The "properties of the value it returns" are, by design, implementation-dependent. You're only supposed to use the id function if you need to know something about what's going on under the hood. The id function is working exactly as intended: it's exposing aspects of the implementation, if for some reason you need to know that stuff.

It would not be a positive change to sacrifice Python performance in order to make the output of id() more intuitive. I've spent many hundreds of hours coding Python and I don't believe I ever used that function or saw someone else use it.

Re:What the Fuck Python by zahlman on Saturday July 19, 2025 @05:05PM (#44619400)
`id()` is documented and mandated to exist, and the result provides guarantees that make it suitable for identity (not equality) checks[1] (although of course you should normally use the `is` operator). Pitfalls involving it are generally really pitfalls with understanding object lifetimes[2].

[1]: https://docs.python.org/3/library/functions.html#id

[2]: see e.g. https://stackoverflow.com/questions/52096582