Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I just spend two days chasing a bug because someone shoved a variable inside a dataclass in the wrong place, nothing is immutable in python.


No, strings are immutable, despite the semantic gymnastics this article is performing.


Strings are immutable on the Python side. On the C size, however, PyUnicode_Resize is part of the PEP 384 Stable ABI and very specifically tries to resize the string in-place (it's normally intended for string-building).


If it is immutable from the client’s perspective, it’s immutable. Anything else is ill-defined.


The C api is “from a client’s perspective”. Any rando can build native modules with it.


I stand corrected.


In javascript I enforce immutability by hitting people over the head when they try to mutate something they're not supposed to.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: