Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
postit
on Feb 15, 2021
|
parent
|
context
|
favorite
| on:
Python strings are immutable, but only sometimes
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.
iainmerrick
on Feb 15, 2021
|
next
[–]
No, strings are immutable, despite the semantic gymnastics this article is performing.
masklinn
on Feb 15, 2021
|
parent
|
next
[–]
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).
ymbeld
on Feb 15, 2021
|
root
|
parent
|
next
[–]
If it is immutable from the client’s perspective, it’s immutable. Anything else is ill-defined.
masklinn
on Feb 15, 2021
|
root
|
parent
|
next
[–]
The C api is “from a client’s perspective”. Any rando can build native modules with it.
ymbeld
on Feb 16, 2021
|
root
|
parent
|
next
[–]
I stand corrected.
mcv
on Feb 16, 2021
|
prev
[–]
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: