3 ms·
As others commented "safety" is a heavily overloaded term, for instance there's "type safety" [1] and "memory safety" [2], and then there's "static vs dynamic t
by emmanueloga_ 2y ago
As others commented "safety" is a heavily overloaded term, for instance there's "type safety" [1] and "memory safety" [2], and then there's "static vs dynamic typing" [3], and "weak vs strong typing" [4], so talking about types and safety offered by a language can be very nuanced.
I suspect when you say "unsafe by design" you may be referring to the dynamic type checking aspect of Python, although Python has supported for a while type annotations, that can be statically checked by linter-like tools like PyRight.
--
1: https://en.wikipedia.org/wiki/Type_safety https://en.wikipedia.org/wiki/Type_safety
2: https://en.wikipedia.org/wiki/Memory_safety https://en.wikipedia.org/wiki/Memory_safety
3: https://en.wikipedia.org/wiki/Type_system#Type_checking https://en.wikipedia.org/wiki/Type_system#Type_checking
4: https://en.wikipedia.org/wiki/Strong_and_weak_typing https://en.wikipedia.org/wiki/Strong_and_weak_typing
- d0mine 2y agoPython both type and memory safe e.g., ""+1 in Python is TypeError and [][0] is IndexError But you can perform unsafe operations e.g., import ctypes ctypes.string_at(0) # access 0 address in memory -> segfault
- eru 2y agoYes, though `ctypes' is kind of marked as `unsafe' in Python by convention.