#python #books
Ссылки на посты по книжке "Л. Рамальо. Python – к вершинам мастерства: Лаконичное и эффективное программирование" (в оригинале - Fluent Python, 2nd Edition). Содержат материал, который показался мне интересным и вошёл в категорию #codegems.
Затрагиваются механизмы сопоставления (match), классы данных и их аналоги, аннотирование типами, инструменты itertools, работа с классами/ООП, генераторы, контекстные менеджеры, асинхронка, дескрипторы классов.
Пробегитесь по темам, если есть незнакомые слова, возможно, есть смысл перечитать актуальную доку Питон )
1. [], {} и ()/match/ChainMap/MappingProxyType
2. class init/dict/json
3. unicode: NFC/NDF, strxfrm/NamedTuple/dataclass
4. more dataclass/typehints
5. weakrefs/functional programming/more typehints
6. Any/|/TypeVar/TypeAlias/typing.Protocol
7. positional-only/closures/singledispath/decorator via class
8. getattr/reduce via initializer/zip,zip_longest/principle of failing fast
9. goose typing/vurtual subclass/Hashable/ABC/Decimal
10. UserDict, UserList, UserString/MRO/mixin/get_annotations
11. (sub)generator/coprogram/type: ignore/with/@contextmanager
12. else in for,while,try/scientific sins/GIL/getswitchinterval/asyncio
13. asyncio.to_thread/asyncpg/asyncio.Semaphore/async with/keyword.iskeyword
14. property/vars/metaprogramming
15. class descriptors
Если решите читать книгу - ТОЛЬКО в оригинале, русский перевод плох.
Ссылки на посты по книжке "Л. Рамальо. Python – к вершинам мастерства: Лаконичное и эффективное программирование" (в оригинале - Fluent Python, 2nd Edition). Содержат материал, который показался мне интересным и вошёл в категорию #codegems.
Затрагиваются механизмы сопоставления (match), классы данных и их аналоги, аннотирование типами, инструменты itertools, работа с классами/ООП, генераторы, контекстные менеджеры, асинхронка, дескрипторы классов.
Пробегитесь по темам, если есть незнакомые слова, возможно, есть смысл перечитать актуальную доку Питон )
1. [], {} и ()/match/ChainMap/MappingProxyType
2. class init/dict/json
3. unicode: NFC/NDF, strxfrm/NamedTuple/dataclass
4. more dataclass/typehints
5. weakrefs/functional programming/more typehints
6. Any/|/TypeVar/TypeAlias/typing.Protocol
7. positional-only/closures/singledispath/decorator via class
8. getattr/reduce via initializer/zip,zip_longest/principle of failing fast
9. goose typing/vurtual subclass/Hashable/ABC/Decimal
10. UserDict, UserList, UserString/MRO/mixin/get_annotations
11. (sub)generator/coprogram/type: ignore/with/@contextmanager
12. else in for,while,try/scientific sins/GIL/getswitchinterval/asyncio
13. asyncio.to_thread/asyncpg/asyncio.Semaphore/async with/keyword.iskeyword
14. property/vars/metaprogramming
15. class descriptors
Если решите читать книгу - ТОЛЬКО в оригинале, русский перевод плох.
Telegram
Aspiring Data Science
#python #codegems
По умолчанию любой экземпляр пользовательского класса считается истинным, но положение меняется, если реализован хотя бы один из методов bool или len. Функция bool(x), по существу, вызывает x.bool() и использует полученный результат. Если…
По умолчанию любой экземпляр пользовательского класса считается истинным, но положение меняется, если реализован хотя бы один из методов bool или len. Функция bool(x), по существу, вызывает x.bool() и использует полученный результат. Если…
⚡1
#python #pyccolo
Хакинг и сабклассинг питона. Для меня это уж слишком, но вдруг кому ТАКОЙ уровень гибкости нужен.
https://www.youtube.com/watch?v=8UesBrSt7wY
Хакинг и сабклассинг питона. Для меня это уж слишком, но вдруг кому ТАКОЙ уровень гибкости нужен.
https://www.youtube.com/watch?v=8UesBrSt7wY
YouTube
Stephen Macke - Python as a Hackable Language for Interactive Data Science | PyData Global 2023
www.pydata.org
Did you know that the core Python syntax and semantics can be tailored for interactive computing use cases? It turns out that more is possible than what you would expect! For example, at the most basic level, Jupyter supports basic syntax…
Did you know that the core Python syntax and semantics can be tailored for interactive computing use cases? It turns out that more is possible than what you would expect! For example, at the most basic level, Jupyter supports basic syntax…
👍1
#python #codegems #chainmap
https://towardsdev.com/what-99-of-python-developers-dont-know-about-chainmap-and-why-it-s-a-game-changer-d9e749f965df
https://towardsdev.com/what-99-of-python-developers-dont-know-about-chainmap-and-why-it-s-a-game-changer-d9e749f965df
Medium
What 99% of Python Developers Don’t Know About ChainMap (And Why It’s a Game-Changer
“Knowledge is power, but knowledge without implementation is useless.” — Charles F. Kettering
#python #optuna #nogil
Что интересно, в Оптуне потестили питон 3.13 без GIL-а, получили по сути ухудшение скорости.
https://medium.com/optuna/overview-of-python-free-threading-v3-13t-support-in-optuna-ad9ab62a11ba
Что интересно, в Оптуне потестили питон 3.13 без GIL-а, получили по сути ухудшение скорости.
https://medium.com/optuna/overview-of-python-free-threading-v3-13t-support-in-optuna-ad9ab62a11ba
Medium
Overview of Python Free Threading (v3.13t) Support in Optuna
In Python 3.13, experimental support for free threading has been introduced, as proposed in PEP 703. Until now, the Python interpreter…
#python #debugging #ic #icecream
https://medium.com/pythoneers/debugging-in-python-replace-print-with-ic-and-do-it-like-a-pro-18f330c863cb
from icecream import ic
# Using ic() to debug
ic(add(10, 20))
ic(add(30, 40))
ic| add(10, 20): 30
ic| add(30, 40): 70
ic.disable() # Disables ic()
ic(multiply(3, 3)) # Prints nothing
ic.enable() # Re-enables ic()
ic(multiply(3, 3)) # Output: ic| multiply(3, 3): 9
def log_to_file(text):
with open("debug.log", "a") as f:
f.write(text + "\n")
ic.configureOutput(prefix="DEBUG| ", outputFunction=log_to_file)
ic(multiply(7, 7))
https://medium.com/pythoneers/debugging-in-python-replace-print-with-ic-and-do-it-like-a-pro-18f330c863cb
Medium
Debugging in Python: Replace print() with ic() and Do It Like a Pro
Introduction:
✍1
#python #functools
https://blog.stackademic.com/pythons-functools-library-the-hidden-gem-for-advanced-programming-23760d8e3de5
https://blog.stackademic.com/pythons-functools-library-the-hidden-gem-for-advanced-programming-23760d8e3de5
Medium
Python’s functools Library: The Hidden Gem for Advanced Programming
When was the last time you used Python’s functools module? If your answer is "never" or "rarely," you’re not alone. Often overshadowed by…
#python #speed
Хорошее перечисление основных подходов к оптимизации питоновского кода.
https://medium.com/@yashwanthnandam/think-python-is-slow-try-these-hacks-for-3x-faster-scripts-today-fbe258ec93bd
Хорошее перечисление основных подходов к оптимизации питоновского кода.
https://medium.com/@yashwanthnandam/think-python-is-slow-try-these-hacks-for-3x-faster-scripts-today-fbe258ec93bd
Medium
Think Python Is Slow? Try These Hacks for 3x Faster Scripts Today
Why investing time in optimization pays off big
#python #codestyle #codegems
Есть о чём задуматься, типа конструкций
https://levelup.gitconnected.com/12-production-grade-python-code-styles-ive-picked-up-from-work-ad32d8ae630d
Есть о чём задуматься, типа конструкций
for elem in mylist or []:https://levelup.gitconnected.com/12-production-grade-python-code-styles-ive-picked-up-from-work-ad32d8ae630d
Medium
12 Production-Grade Python Code Styles I’ve Picked Up From Work
Read Free…