#241 f-yes we want some f-string tricks!

Python Bytes - Podcast tekijän mukaan Michael Kennedy and Brian Okken - Maanantaisin

Kategoriat:

Watch the live stream: Watch on YouTube About the show Sponsored by us: Check out the courses over at Talk Python And Brian’s book too! Special guest: Jay Miller Michael #1: Autosync all branches of a fork Use GitHub actions to keep your fork in sync Step 1: make changes in a separate branch (a branch other than main) to keep the working tree clean and avoiding conflicts with upstream Step 2: Add a new workflow under the “actions” section. We are going to follow the Fork-Sync-With-Upstream-action from the Actions Marketplace. Copy the YAML in the article being careful to use the right repo/branch names Step 3: click on Start Commit and Commit new file and that's it! See your running workflow in the actions tab Brain #2: Measuring memory usage in Python: it’s tricky! Itamar Turner-Trauring Nice, easy to follow discussion of memory Cool example to allocate 3 GB arr = np.ones((1024, 1024, 1024, 3), dtype=np.uint8) that’s a 4 dimensional array of bytes, 1k x 1k x 1k x 3 “Resident Memory” measured with psutil.Process().memory_info().rss rss = “Resident Set Size”, or “non-swapped physical memory” returns bytes, so / (1024 * 1024) gives MB Shows a little more than 3 GB Doing nothing to process, but opening a few tabs in a browser and re-running rss shows a reduction due to some memory being saved to disk. Fil profiler can show peak allocated memory. Memory Resident Memory : RAM usage Allocated Memory : what we asked for, not really measurable Peak Allocated Memory : kinda the same, but not, and it’s measurable Tradeoffs between measuring the two Jay #3: Python f-strings can do more than you thought. f'{val=}', f'{val!r}', f'{dt:%Y-%m-%d}' Caution! Just because you can doesn’t mean you should but sometimes you will be looking for a way to do something Michael #4: 10 Tips and Tools You Can Adopt in 15 minutes or Less To Level Up Your Dev Productivity Upgrade your shell (ohmyzsh or ohmyposh) + Windows Terminal with PS 7 Secure.py (or NWebSec for ASP.NET or …) Use a UI for git (SourceTree, GitHub Desktop, PyCharm, VS Code, etc) Sync your github forks Use a good logging framework: Logbook, Loguru, even Sentry SSL/TLS with Let’s Encrypt 80/20 testing with sitemaps PageSpeed insights (e.g for Python Bytes) Use an OS package manager: Homebrew, Chocolaty, or Linux’s built in) Manage your dependencies with dependabot or even pip-compile requirements.in --upgrade Full conference video Brian #5: How to Start a Production-Ready Django Project Vitor Freitas Some great points for really any project, not just Django projects Make sure different environments work with the project, in this priority: local, so clone and run is easy and new people can onboard fast test, also local, so devs actually test with no issues production, can be more complicated since only experienced people will need it, or it will get run by your CI/CD chain production is also used in staging Configure git and venv from the beginning. Cool requirements files example with a requirements directory containing base.txt test.txt : base.txt + test stuff local.txt : test.txt + dev stuff production.txt : base.txt + any production only stuff Settings setup, also with switched implementation for local, test, prod Shared editor configuration, interesting addition Shared linting and styling tools, isort, black, flake8, … There are some Django specifics also, like app structure. Jay #6: Bunch macOS application that allows you to create starting and finishing workflows How Jay sets up and tears down the newsletter video Extras Jay Monodraw - Make diagrams or outlines using ascii art Joke

Visit the podcast's native language site