Timeline for answer to Python function that deeply "freezes" an object by J_H
Current License: CC BY-SA 4.0
Post Revisions
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 4, 2025 at 19:55 | comment | added | Marco Sulla |
Anyway, do you have any suggestion about the correctness of the code? For example, is it good to convert the object in a frozendict if it has a __dict__ attribute? Is it good to consider the object immutable if it's hashable? And so on
|
|
| Mar 4, 2025 at 19:52 | comment | added | Marco Sulla | - modern type hinting: I'm forced to use the .pyi because there's not only the pure py implementation, but a C extension. | |
| Mar 4, 2025 at 19:52 | comment | added | Marco Sulla |
- be explicit: well, I like o :D but maybe I can improve the docstring a little - lint: yes, maybe it's better to adhere to PEP 8 - optional type hints: well, the type hints are in init.pyi - There are some places in the GitHub repo where we test for sys.version: well, the only place I use it to stop the code is in run_type_checker.py, that runs a static type checker using typing_extensions.assert_type, that is available only for 3.9+. But it's for testing only.
|
|
| Mar 4, 2025 at 19:51 | comment | added | Marco Sulla |
I'm forced to add multiple comments. - imports at top: well, I have that import also at top, but for cleaning I delete the imported module at the end. In this way the module can't pollute the autocomplete of an IDE or dir(). - extract helper: I'll think about it, even if I'm reluctant to create a "subfunction" that is used in one place only
|
|
| Mar 4, 2025 at 2:09 | history | edited | J_H | CC BY-SA 4.0 |
added 6 characters in body
|
| Mar 4, 2025 at 2:04 | history | answered | J_H | CC BY-SA 4.0 |