CyrilBrulebois, Just reminded that #Python's considerations to anything packaging-related is a trashfire: deprecating distutils, including distutils.version, pointing to an external module that provides “Reusable core utilities for various Python Packaging interoperability specifications.”
ramikrispin, (1/5) 𝐇𝐚𝐩𝐩𝐲 𝐒𝐚𝐭𝐮𝐫𝐝𝐚𝐲! ☀️
Here are a few steps you can take to reduce your Python 🐍 image size 👇🏼TLDR - Using slim image and multi-stage build
ramikrispin, (2/5) 𝐒𝐥𝐢𝐦 𝐢𝐦𝐚𝐠𝐞
Typically, I use the Python official image as the baseline for setting up a dockerized Python environment. The official Python image offers multiple images for different Linux flavors and CPU architectures. The default image (e.g., 𝘱𝘺𝘵𝘩𝘰𝘯:𝘭𝘢𝘵𝘦𝘴𝘵) has comprehensive supporting tools that impact the image size - 1 GB.A simple way to reduce the image size is to replace the default image with a slim version that is 150 MB (compared to 1GB) 🚀.
davidism, (edited ) Announcing Flask-SQLAlchemy-Lite, a new lightweight replacement for Flask-SQLAlchemy that provides engine configuration and session lifetime, but none of the other custom stuff in the prior extension. It works with Flask and Quart, sync and async. I figured out the core idea on the flight to PyCon US, teased it during FlaskCon, and now it's available! Check out the docs to get started! https://flask-sqlalchemy-lite.readthedocs.io #Python #Flask #SQLAlchemy
ThePSF, There are still a few days left to take advantage of the latest #HumbleBundle package from @nostarch: Dive into DevOps!
You can pick up 5 great titles for just $1, or go up to $35 for all 22 items in this "indispensable IT library".
Either way, be sure to use "Adjust Donation" to choose how much of your purchase goes to the PSF🐍❤️https://www.humblebundle.com/books/dive-into-dev-ops-no-starch-books
#python
https://www.humblebundle.com/books/dive-into-dev-ops-no-starch-books
bbelderbos, @treyhunner does a deep dive of #Python's many command-line utilities. 🙏 🔥
First of all it's good to know that you can use
-m
to run a Python module as if it were a script 💡There are some nifty ones like inspect / json.tool / zipapp. You'll surely pick up new ones ... 💪
shaft, (edited ) French Ah mais #Python 3.10 ajoute une déclaration "match" qui permet d'éviter les longues liste de "if...elif...elif..."
À la place on met:
match la_variable:
\t case "a":
...
\t case "b":
...
\t case _:
Ici un "catch-all"https://docs.python.org/3/tutorial/controlflow.html#match-statements
shaft, French @CM63 Le serpent met du temps à digérer et donc assimiler ce qui ce fait ailleurs :)
shaft, (edited ) French Haaaan et on peut faire:
case "truc" if bidule:
Ex, sur un parser d'enregistrement DNS
match rr_type:
....case 46 if dnssec:
...(Le type de Resource Record 46 étant RRSIG)
J'aurai du #RTFM avant moi
dragfyre, (edited ) Alright #python and #CS heads, here's a little puzzle for you to ponder.
I tried implementing the square root estimation algorithm from #SICP Lecture 1A in Python just for fun (my Lisp skills are weak).
Code: https://cryptpad.fr/code/#/2/code/view/W2yHJixW0qyk1BnUcxIwGtxAKszQ54qPngLI9ztwfx8/ (also, see image.)
Notably, I made the precision variable so that I could see how precise a value I could get. I tried it at lower precision at first and it worked, so I bumped it up. Seemed to work fine, until I got past 16 significant digits... (1/3)
dragfyre, At that point, I noticed that the values started to diverge at around the 16th decimal place, and it didn't get better as precision increased. In fact, I checked the answer against a calculator app and got a different answer, with completely different digits after the 16th place. So I thought, OK, it's a hardware precision issue.
BUT THEN I tried to estimate the square roots of other numbers (ex.: 1.7, 13, 33) and the difference was ZERO. That is, ONLY the square root of 2 diverged. (2/3)
loke, (edited ) @dragfyre There is nothing wrong with your algorithm. It gives the correct result within the precision of the number representation you're using.
In your case, you're hitting the limits of 64-bit floating point, and the reason you are getting different results is because the implementation of sqrt that Python uses (which appears to be the default libc implementation) is more accurate than yours for some specific inputs.
I took the libery to do an almost 1-to-1 port of your code to Kap, which allows you to try the same thing using rational arithmetic. When you do so, you get a value that is as precise as you tolerance value:
Click "send" to run the code.
Kap version of the code which supports both types of numbers
I also took your code and tested it on a 100 different values (0 to 5 with a step length of 0.05, and it gives you several other values for which your algorithm gives an imprecise value with floating point arithmetic:
hugovk, 🎉 We just had 3 successful core dev votes in parallel!
Each dev focuses on different yet important areas, reflecting the size & breadth of the CPython project.
Please give a big welcome to:
🍏 @freakboy3742 added iOS support (#PEP730)
https://discuss.python.org/t/vote-to-promote-russell-keith-magee/53821🐛 Tian Gao works on the pdb debugger
https://discuss.python.org/t/vote-to-promote-tian-gao/53895🏎️ @mdboom works on benchmarking in the Faster CPython team
https://discuss.python.org/t/vote-to-promote-michael-droettboom/54227That's 5 new so far this year, same as last year 🚀
https://hugovk.github.io/python-core-devs/by-year.html
#Python #CPython
retiolus, Now I run my own #BitTorrent tracker! 🤯
https://pybittrack.retiolus.net/
https://pybittrack.retiolus.net/announce
and of course, it is open source: https://codeberg.org/retiolus/pybittrack
ThePSF, We want your vote! Every voting-eligible PSF Member (Supporting, Managing, Contributing, and Fellow) needs to affirm their membership to vote in this year’s Board election to ensure that we meet quorum as required by our bylaws 🗳️ #python
https://pyfound.blogspot.com/2024/06/affirm-your-psf-membership-voting-status.html
nedbat, Mostly you shouldn't subclass #Python built-in types. But if you do, dict subclasses can define missing: it's called when a key is missing. Instead of hiding a dict in a function as a cache, how about hiding a function in a dict!? A Fibonacci dictionary:
leahawasser, i wrote another blog post on my personal experiences with packaging as a teacher, a user and a maintainer. And how giving a tech talk on a big stage felt! (hint: scary!)
i'm curious if others have experienced imposter syndrome and/or challenges navigating our #python packaging ecosystem / data science ecosystem! let me know what you think. 💗
https://www.pyopensci.org/blog/python-packaging-friends-dont-let-friends-package-alone.html
phildini, Oh this is extremely handy... someone on the #python core team seems to be really focusing on CLI utilities and I love this
https://mastodon.social/@treyhunner/112554261035770847
ehmatthes,
webology, @ehmatthes it's about 2x to 3x faster for me too. Switching from "pip-tools compile" to "uv pip compile" is a made-up 10x faster.
I also noticed a huge speed-up when re-installing via uv over pip. Same with the --upgrade flag.
nedbat, Nested loops can sometimes be replaced by one itertools.product() from the #Python stdlib:
nedbat, Are you sure you know how #Python decorators work? This should be no problem! 😈 🤯 🤓
e_nomem, @nedbat It took me a moment to remember that the execution happens at load but yeah, you can do some pretty bonkers stuff with decorators.
brohrer, @nedbat thanks for keeping me grounded
(From https://blog.gardeviance.org/2008/04/three-stages-of-expertise.html?m=1)
villares, Portuguese Code at: https://github.com/villares/sketch-a-day/tree/main/2024/sketch_2024_06_04
More sketch-a-day: https://abav.lugaralgum.com/sketch-a-day
I really need your support to keep going, if you can, donate any amount at: https://www.paypal.com/donate/?hosted_button_id=5B4MZ78C9J724 #Processing #Python #py5 #CreativeCoding
hugovk, 📣🐍📚 Calling all Python library maintainers!
Python 3.13 is now in beta, with the second of four beta releases out later today!
It's now time to start testing your libraries with 3.13 and report any problems back to CPython so they can be fixed before the big October release. And make any updates you need to upgrade your library; keep an eye out for removals and deprecations.
Here's how to test 3.13 on GitHub Actions:
hynek, @hugovk My understanding is they already fixed it months ago. Guessing their release process is painful.
cfbolz,
Posit, posit::conf(2024) virtual tickets are now available!
Join us on August 12-14—from all over the world—to live stream the incredible talks and keynotes that will be taking place in Seattle.We understand that not everyone will be able to make the trip to Seattle this year, so we’re excited to offer a fully virtual offering for everyone as an alternate option.
REGISTER: https://posit.co/conference/
Posit, And if you’re available on June 6, join the Data Science Hangout where you can ask any questions you may have about posit::conf(2024) directly to the conf committee including Hadley Wickham, Posit’s Chief Scientist. https://posit.co/data-science-hangout/
pytexas, Reminder that the PyTexas Meetup is tonight! Come by and chat, hangout, and hear about a journey building an AI app. We'll get started chatting around 7:30pm CST and move on to the main presentation at 8:00pm.
See y'all there!
desertplains,
desertplains, @tshirtman @diazona humm interesting. I hope I'm not abusing from your good will but, would you mind to elaborate a bit more, or even send some article for reference? I got curious with the "arbitrarily large numbers". Tks.
tshirtman, @desertplains
https://docs.python.org/3/library/stdtypes.html#typesnumeric says "Integers have unlimited precision" which is to mean it can use as much memory as needed to store bigger values (until your operating system refuses to give more memory to your process). it's not like the C int type, for example, which will have minimum and maximum possible values.
@diazona
treyhunner, (edited ) New article on Python's many command-line tools 📣
Did you know that #Python 3.12 comes bundled with 50 command-line tools? 😮
An HTTP server, a sqlite prompt, a code profiler, and so much more! ✨
hugovk, @treyhunner Coming soon in #Python 3.13: a random CLI! 🎲
$ python -m random curry "fish n chips" tacos
curry$ python -m random 6
6
treyhunner, @hugovk Ooh! I missed this new feature!
This one actually seems really handy 💖
$ python3.13 -m random 6
1
$ python3.13 -m random 3.14159
3.0145311549545397
$ python3.13 -m random this is great
isI will definitely be updating this article before October. 😁
villares, Portuguese Code at: https://github.com/villares/sketch-a-day/tree/main/2024/sketch_2024_06_03
More sketch-a-day: https://abav.lugaralgum.com/sketch-a-day
I really need your support to keep going, if you can, donate any amount at: https://www.paypal.com/donate/?hosted_button_id=5B4MZ78C9J724 #Processing #Python #py5 #CreativeCoding
cheukting_ho, Hey, do you want to vote in the upcoming @ThePSF elections? Don't forget to affirm your intention to vote (please check your email, including spam). Deadline: June 25th 2024. Not a member yet? Check how you can become a voting member here: https://buff.ly/3X2cLhL #Python
leahawasser, I wrote an overview of @pyOpenSci s second (and my second) experience at #pyconus2024 https://www.pyopensci.org/blog/recap-pyos-pyconus-2024.html
we had a great time with a record amount of sprinters, open space attendees AND i gave my first talk! I can't wait for next year! #python #openscience #opensource