#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…
#python #typing
Про Final не знал. Self, TypeAlias, Literal заслуживают внимания.
На самом деле всё ещё сложнее с TypeVar.
https://medium.com/techtofreedom/8-levels-of-using-type-hints-in-python-a6717e28f8fd
Про Final не знал. Self, TypeAlias, Literal заслуживают внимания.
На самом деле всё ещё сложнее с TypeVar.
https://medium.com/techtofreedom/8-levels-of-using-type-hints-in-python-a6717e28f8fd
Medium
8 Levels of Using Type Hints in Python
To make your programs more readable and easier to debug
👀1
#python #security #pypi
"Проблема возникла из-за удаления зависимости msgspec-python313-pre из репозитория PyPI (Python Package Index), который содержит тысячи сторонних модулей для Python. Злоумышленники добавили в репозиторий вредоносный пакет с тем же именем, который даёт им возможность удалённого выполнения произвольного кода на уязвимых системах, что может привести к компрометации данных, краже информации и полному контролю над заражённым ПК."
https://3dnews.ru/1119504/millioni-kompyuterov-okazalis-pod-ugrozoy-vzloma-izza-kriticheskoy-uyazvimosti-svyazannoy-s-python
"Проблема возникла из-за удаления зависимости msgspec-python313-pre из репозитория PyPI (Python Package Index), который содержит тысячи сторонних модулей для Python. Злоумышленники добавили в репозиторий вредоносный пакет с тем же именем, который даёт им возможность удалённого выполнения произвольного кода на уязвимых системах, что может привести к компрометации данных, краже информации и полному контролю над заражённым ПК."
https://3dnews.ru/1119504/millioni-kompyuterov-okazalis-pod-ugrozoy-vzloma-izza-kriticheskoy-uyazvimosti-svyazannoy-s-python
3DNews - Daily Digital Digest
Миллионы компьютеров оказались под угрозой взлома из-за критической уязвимости, связанной с Python
В популярном пакете объектно-ориентированного языка программирования Python — python-json-logger — обнаружена критическая уязвимость, которой присвоен код CVE-2025-27607.
#python
Не сказал бы, что эти фичи прямо меняют правила игры. Но неплохо. В целом, отладка как была в питоне дерьмовой, так и осталась.
https://medium.com/@huzaifazahoor654/python-3-14-is-here-5-game-changing-features-you-should-know-0a197bac9708
Не сказал бы, что эти фичи прямо меняют правила игры. Но неплохо. В целом, отладка как была в питоне дерьмовой, так и осталась.
https://medium.com/@huzaifazahoor654/python-3-14-is-here-5-game-changing-features-you-should-know-0a197bac9708
Medium
Python 3.14 Is Here: 5 Game-Changing Features You Should Know
Explore Python 3.14 features with this Python 3.14 tutorial. From template strings to lazy evaluation, discover what’s new in Python 3.14…
#algorithms #bloomfilter #hyperloglog #minhash #lshforest #fastquantile #rollingquantiles #python #codegems
https://youtu.be/rOi0fybeUf8?si=FvW-LWy8Bo0QFIer
https://youtu.be/rOi0fybeUf8?si=FvW-LWy8Bo0QFIer
YouTube
Артур Соловьёв | Fast and approximate responses
Спикер: Артур Соловьёв, HFT, Senior Engineer
Data Fest 2025: https://ods.ai/events/datafest2025
Презентацию к докладу Вы можете скачать в треке секции OptimalDL: https://ods.ai/tracks/df25-optimaldl
______
Наши соц.сети:
Telegram: https://t.me/datafest
Вконтакте:…
Data Fest 2025: https://ods.ai/events/datafest2025
Презентацию к докладу Вы можете скачать в треке секции OptimalDL: https://ods.ai/tracks/df25-optimaldl
______
Наши соц.сети:
Telegram: https://t.me/datafest
Вконтакте:…
#python #testing #pytest
Что делать, если у вас сотни (или даже тысячи) тестов в проекте, не ждать же сутками когда pytest их последовательно переберёт?
Ставим
Тогда добавляем флаги
Оптимальное решение: сначала запускаем тесты с разумной параллельностью не создавая отчёты, потом последовательно проходим подозрительные с этапа 1, используя флаг -lf:
Что делать, если у вас сотни (или даже тысячи) тестов в проекте, не ждать же сутками когда pytest их последовательно переберёт?
Ставим
pip install pytest-xdist, и запускаем pytest -n auto, но и тут опасность. Часто бывает, что тесты из одних и тех же файлов/классов конкурируют за одни ресурсы - файлы, gpu, etc.Тогда добавляем флаги
--dist=loadfile или --dist=loadscope, чтобы снизить конкуренцию за ресурсы и сохранить какую-то параллельность. Но даже при таком подходе будут ложноположительный фэйлы.Оптимальное решение: сначала запускаем тесты с разумной параллельностью не создавая отчёты, потом последовательно проходим подозрительные с этапа 1, используя флаг -lf:
pytest tests/ -n auto --maxprocesses=32 --dist loadscope && exit 0 || pytest tests/ -vv --lf