Episodes

  • #392 The votes have been counted
    Jul 17 2024
    Topics covered in this episode: 2024 PSF Board Election & Proposed Bylaw Change ResultsSATYRN: A modern Jupyter client for MacIncident Report: Leaked GitHub Personal Access TokenExtra extra extraExtrasJokeWatch on YouTube About the show Sponsored by Code Comments, an original podcast from RedHat: pythonbytes.fm/code-comments Connect with the hosts Michael: @mkennedy@fosstodon.orgBrian: @brianokken@fosstodon.orgShow: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Brian #1: 2024 PSF Board Election & Proposed Bylaw Change Results New board members Tania AllardKwonHan BaeCristián Maureira-FredesCongrats to new board membersIf you want to consider becoming a board member, there are 4 seats up for vote next year.All 3 bylaw changes passed, by a wide margin. Details of changesChange 1: Merging Contributing and Managing member classesChange 2: Simplifying the voter affirmation process by treating past voting activity as intent to continue votingChange 3: Allow for removal of Fellows by a Board vote in response to Code of Conduct violations, removing the need for a vote of the membership Michael #2: SATYRN: A modern Jupyter client for Mac A Jupyter client app for macOSComes with a command paletteLLM assistance (local or cloud?)Built in Black formatterCurrently in alphaBusiness model unknown Brian #3: Incident Report: Leaked GitHub Personal Access Token Suggested by Galen SwintSee also JFrog blog: Binary secret scanning helped us prevent (what might have been) the worst supply chain attack you can imagineA GitHub access token found it’s way into a .pyc file, then into a docker image.JFrog found it through some regular scans.JFrog notified PYPI security.Token was destroyed within 17 minutes. (nice turnaround)Followup scan revealed that no harm was done.Takaways (from Ee Durbin): Set aggressive expiration dates for API tokens (If you need them at all)Treat .pyc files as if they were source codePerform builds on automated systems from clean source only. Michael #4: Extra extra extra Python 3.13.0 beta 3 releasedIce got a lot betterI Will Piledrive You If You Say AI Again | Prime Reacts VideoFollow up actions for polyfill supply chain attackDeveloper Ecosystem Survey 2024Code in a Castle still has seats open Extras Brian: A new pytest course in the works Quick course focusing on core pytest features + some strategy and Design for Testability conceptsIdea everyone on the team (including managers) can take the new course.1-2 people on a team take “The Complete pytest Course” to become the teams local pytest experts.Python People is on an indefinite hold Python Test → back to Test & Code (probably) I’m planning a series (maybe a season) on TDD which will be language agnostic.Plus I still have tons of Test & Code stickers and no Python Test stickers.New episodes planned for August Joke: I need my intellisense (autocomplete)
    Show more Show less
    26 mins
  • #391 A weak episode
    Jul 9 2024
    Topics covered in this episode: Vendorize packages from PyPIA Guide to Python's Weak References Using weakref ModuleMaking Time SpeakHow Should You Test Your Machine Learning Project? A Beginner’s GuideExtrasJokeWatch on YouTube About the show Sponsored by Code Comments, an original podcast from RedHat: pythonbytes.fm/code-comments Connect with the hosts Michael: @mkennedy@fosstodon.orgBrian: @brianokken@fosstodon.orgShow: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Michael #1: Vendorize packages from PyPI Allows pure-Python dependencies to be vendorized: that is, the Python source of the dependency is copied into your own package.Best used for small, pure-Python dependencies Brian #2: A Guide to Python's Weak References Using weakref Module Martin HeinzVery cool discussion of weakrefQuick garbage collection intro, and how references and weak references are used.Using weak references to build data structures. Example of two kinds of treesImplementing the Observer patternHow logging and OrderedDict use weak references Michael #3: Making Time Speak by Prayson, a former guest and friend of the showTranslating time into human-friendly spoken expressionsExample: clock("11:15") # 'quarter past eleven' Features Convert time into spoken expressions in various languages.Easy-to-use API with a simple and intuitive design.Pure Python implementation with no external dependencies.Extensible architecture for adding support for additional languages using the plugin design pattern. Brian #4: How Should You Test Your Machine Learning Project? A Beginner’s Guide François PorcherUsing pytest and pytest-cov for testing machine learning projectsLots of pieces can and should be tested just as normal functions. Example of testing a clean_text(text: str) -> str functionTest larger chunks with canned input and expected output. Example test_tokenize_text()Using fixtures for larger reusable components in testing Example fixture: bert_tokenizer() with pretrained dataChecking coverage Extras Michael: Twilio Authy Hack Google Authenticator is the only option? Really?Bitwarden to the rescueRequires (?) an update to their app, whose release notes (v26.1.0) only say “Bug fixes”Introducing Docs in Proton Drive This is what I called on Mozilla to do in “Unsolicited Advice for Mozilla and Firefox” But Proton got there firstEarly bird ending for Code in a Castle course Joke: I Lied
    Show more Show less
    26 mins
  • #390 Coding in a Castle
    Jul 2 2024
    Topics covered in this episode: Joining Strings in Python: A "Huh" Moment10 hard-to-swallow truths they won't tell you about software engineer jobMy thoughts on Python in ExcelExtra, extra, extraExtrasJokeWatch on YouTube About the show Sponsored by ScoutAPM: pythonbytes.fm/scout Connect with the hosts Michael: @mkennedy@fosstodon.orgBrian: @brianokken@fosstodon.orgShow: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Brian #1: Joining Strings in Python: A "Huh" Moment Veronica Berglyd OlsenStandard solution to “read lines from a file, do some filtering, create a multiline string”: f = open("input_file.txt") filtered_text = "\n".join(x for x in f if not x.startswith("#")) This uses a generator, file reading, and passes the generator to join.Another approach is to add brackets and pass that generator to a list comprehension: f = open("input_file.txt") filtered_text = "\n".join([x for x in f if not x.startswith("#")]) At first glance, this seems to just be extra typing, but it’s actually faster by 16% on CPython due to the implementation of .join() doing 2 passes on input if passed a generator. From Trey Hunner: “I do know that it’s not possible to do 2 passes over a generator (since it’d be exhausted after the first pass) so from my understanding, the generator version requires an extra step of storing all the items in a list first.” Michael #2: 10 hard-to-swallow truths they won't tell you about software engineer job College will not prepare you for the jobYou will rarely get greenfield projectsNobody gives a BLANK about your clean codeYou will sometimes work with incompetent peopleGet used to being in meetings for hoursThey will ask you for estimates a lot of timesBugs will be your arch-enemy for lifeUncertainty will be your toxic friendIt will be almost impossible to disconnect from your jobYou will profit more from good soft skills than from good technical skills Brian #3: My thoughts on Python in Excel Felix ZumsteinInteresting take on one person’s experience with trying Python in Excel.“We wanted an alternative to VBA, but got an alternative to the Excel formula language”“Python runs in the cloud on Azure Container Instances and not inside Excel.”“DataFrames are great, but so are NumPy arrays and lists.”… lots of other interesting takaways. Michael #4: Extra, extra, extra Code in a castle - Michael’s Python Zero to Hero course in TuscanyPolyfill.io JavaScript supply chain attack impacts over 100K sites Now required reading: Reasons to avoid Javascript CDNsMac users served info-stealer malware through Google adsHTMX for the win!ssh to run remote commands > ssh user@server "command_to_run --arg1 --arg2" Extras Brian: A fun reaction to AI - I will not be showing the link on our live stream, due to colorful language. Michael: Coding in a Castle Developer Education EventPolyfill.io JavaScript supply chain attack impacts over 100K sites See Reasons to avoid Javascript CDNs Joke: HTML Hacker
    Show more Show less
    37 mins
  • #389 More OOP for Python?
    Jun 24 2024
    Topics covered in this episode: Solara UI FrameworkCoverage at a crossroads“Virtual” methods in Python classesExtrasJokeExtrasJokeWatch on YouTube About the show Sponsored by ScoutAPM: pythonbytes.fm/scout Connect with the hosts Michael: @mkennedy@fosstodon.orgBrian: @brianokken@fosstodon.orgShow: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Michael #1: Solara UI Framework via FlorianA Pure Python, React-style Framework for Scaling Your Jupyter and Web AppsSolara lets you build web apps from pure Python using ipywidgets or a React-like API on top of ipywidgets. These apps work both inside the Jupyter Notebook and as standalone web apps with frameworks like FastAPI.See the Examples page.Based on ReactonBy building on top of ipywidgets, Solara automatically leverage an existing ecosystem of widgets and run on many platforms, including JupyterLab, Jupyter Notebook, Voilà, Google Colab, DataBricks, JetBrains Datalore, and more. Brian #2: Coverage at a crossroads Ned Batchelder is working on making coverage.py faster.Includes a nice, quick explanation of roughly how coverage.py works with trace function and arcs used for branch coverage.And how trace slows things down for lines we know are already covered.There are cool ideas from SlipCover that could be applicable.There’s also sys.monitoring from Python 3.12 that helps with line coverage, since you can disable it for lines you already have info on. It doesn’t quite complete the picture for branch coverage, though. Summary: jump in and help if you canread it anyway for a great mental model of how coverage.py works. Michael #3: “Virtual” methods in Python classes via Brian SkinnPEP 698 just got accepted, defining an @override decorator for type hinting, to help avoid errors in subclasses that override methods.Only affects type checkers but allows you to declare a “link” between the base method and derived class method with the intent of overriding it using OOP. If there is a mismatch, it’s an error.Python 3.12’s documentationMakes Python a bit more like C# and other more formal languages Brian #4: Parsing Python ASTs 20x Faster with Rust Evan DoyleTach is “a CLI tool that lets you define and enforce import boundaries between Python modules in your project.” we covered it in episode 384When used to analyze Sentry’s ~3k Python file codebase, it took about 10 seconds. Profiling analysis using py-spy and speedscope pointed to a function that spends about 2/3 of the time parsing the AST, and about 1/3 traversing it.That portion was then rewritten in Rust, resulting in 10x speedup, ending in about 1 second.This is a cool example of not just throwing Rust at a speed problem right away, but doing the profiling homework first, and focusing the Rust rewrite on the bottleneck. Extras Brian: I brought up pkgutil.resolve_name() last week on episode 388 Brett Cannon says don’t use that, it’s deprecatedThanks astroboy for letting me knowWill we get CalVer for Python? it was talked about at the language summitThere’s also pep 2026, in draft, with a nice nod in the number of when it might happen. 3.13 already in the works for 20243.14 slated for 2025, and we gotta have a pi releaseSo the earliest is then 2026, with maybe a 3.26 version ?Saying thanks to open source maintainers Great write-up by Brett Cannon about how to show your appreciation for OSS maintainers. Be niceBe an advocateProduce your own open sourceSay thanksFiscal supportOn topic Thanks Brett for pyproject.toml. I love it. Michael: The Shiny for Python course is out! Plus, it’s free so come and get it. Joke: Tao of Programming: Book 1: Into the Silent Void, Part 1
    Show more Show less
    31 mins
  • #388 Don't delete all the repos
    Jun 18 2024
    Topics covered in this episode: PSF Elections coming upCloud engineer gets 2 years for wiping ex-employer’s code reposPython: Import by string with pkgutil.resolve_name()DuckDB goes 1.0ExtrasJokeWatch on YouTube About the show Sponsored by ScoutAPM: pythonbytes.fm/scout Connect with the hosts Michael: @mkennedy@fosstodon.orgBrian: @brianokken@fosstodon.orgShow: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Brian #1: PSF Elections coming up This is elections for the PSF Board and for 3 bylaw changes.To vote in the PSF election, you need to be a Supporting, Managing, Contributing, or Fellow member of the PSF, …And affirm your voting status by June 25.See Affirm your PSF Membership Voting Status for more details.Timeline Board Nominations open: Tuesday, June 11th, 2:00 pm UTCBoard Nominations close: Tuesday, June 25th, 2:00 pm UTCVoter application cut-off date: Tuesday, June 25th, 2:00 pm UTC same date is also for voter affirmation.Announce candidates: Thursday, June 27thVoting start date: Tuesday, July 2nd, 2:00 pm UTCVoting end date: Tuesday, July 16th, 2:00 pm UTC See also Thinking about running for the Python Software Foundation Board of Directors? Let’s talk! There’s still one upcoming office hours session on June 18th, 12 PM UTCAnd For your consideration: Proposed bylaws changes to improve our membership experience 3 proposed bylaws changes Michael #2: Cloud engineer gets 2 years for wiping ex-employer’s code repos Miklos Daniel Brody, a cloud engineer, was sentenced to two years in prison and a restitution of $529,000 for wiping the code repositories of his former employer in retaliation for being fired.The court documents state that Brody's employment was terminated after he violated company policies by connecting a USB drive. Brian #3: Python: Import by string with pkgutil.resolve_name() Adam JohnsonYou can use pkgutil.resolve_name("[HTML_REMOVED]:[HTML_REMOVED]")to import classes, functions or modules using strings. You can also use importlib.import_module("[HTML_REMOVED]") Both of these techniques are so that you have an object imported, but the end thing isn’t imported into the local namespace. Michael #4: DuckDB goes 1.0 via Alex MonahanThe cloud hosted product @MotherDuck also opened up General AvailabilityCodenamed "Snow Duck"The core theme of the 1.0.0 release is stability. Extras Brian: Sending us topics. Please send before Tuesday. But any time is welcome.NumPy 2.0 htmx 2.0.0 Michael: Get 6 months of PyCharm Pro for free. Just take a course (even a free one) at Talk Python Training. Then visit your account page > details tab and have fun.Coming soon at Talk Python: Shiny for Python Joke: .gitignore thoughts won't let me sleep
    Show more Show less
    22 mins
  • #387 Heralding in a new era of database queries
    Jun 11 2024
    Topics covered in this episode: DataheraldPython's many command-line utilitiesDistroless Pythonfunctools.cache, cachetools, and cacheboxExtrasJokeExtrasJokeWatch on YouTube About the show Sponsored by ScoutAPM: pythonbytes.fm/scout Connect with the hosts Michael: @mkennedy@fosstodon.orgBrian: @brianokken@fosstodon.orgShow: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Michael #1: Dataherald Interact with your SQL database, Natural Language to SQL using LLMs.Allows you to set up an API from your database that can answer questions in plain EnglishUses include Allow business users to get insights from the data warehouse without going through a data analystEnable Q+A from your production DBs inside your SaaS applicationCreate a ChatGPT plug-in from your proprietary data Brian #2: Python's many command-line utilities Trey HunnerToo many to list, but here’s some fun ones json.tool - nicely format json datacalendar - print the calendar current by default, but you can pass in year and monthgzip, ftplib, tarfile, and other unixy things handy on WindowscProfile & pstats Michael #3: Distroless Python via Patrick SmythWhat is distroless anyway? These are container images without package managers or shells included.Debugging these images presents some wrinkles (can't just exec into a shell inside the image), but they're a lot more secure.Chainguard, creates low/no CVE distroless images based on our FOSS distroless OS, Wolfi.Some Python use-cases: docker run -it cgr.dev/chainguard/python:latest # The entrypoint is a Python REPL, since no b/a/sh is included docker run -it cgr.dev/chainguard/python:latest-dev # This is their dev version and has pip, bash, apk, etc. Brian #4: functools.cache, cachetools, and cachebox functools cache and lru_cache - built in cachetools - “This module provides various memoizing collections and decorators, including variants of the Python Standard Library's @lru_cache function decorator.”cachebox - “The fastest caching Python library written in Rust” Extras Brian: Python 3.12.4 is outVSCode has some pytest improvements Michael: Time for a bartender alternative, I’ve switched to Ice.Rocket.chat as an alternative to Slack Joke: CSS Cartoons
    Show more Show less
    28 mins
  • #386 Major releases abound
    Jun 4 2024
    Topics covered in this episode: NumPy 2.0 release date is June 16Uvicorn adds multiprocess workerspixiJupyterLab 4.2 and Notebook 7.2 are availableExtrasJokeWatch on YouTube About the show Sponsored by Mailtrap: pythonbytes.fm/mailtrap Connect with the hosts Michael: @mkennedy@fosstodon.orgBrian: @brianokken@fosstodon.orgShow: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Brian #1: NumPy 2.0 release date is June 16 “This release has been over a year in the making, and is the first major release since 2006. Importantly, in addition to many new features and performance improvement, it contains breaking changes to the ABI as well as the Python and C APIs. It is likely that downstream packages and end user code needs to be adapted - if you can, please verify whether your code works with NumPy 2.0.0rc2.”NumPy 2.0.0 Release NotesNumPy 2.0 migration guide including “try just running ruff check path/to/code/ --select NPY201”“Many of the changes covered in the 2.0 release notes and in this migration guide can be automatically adapted in downstream code with a dedicated Ruff rule, namely rule NPY201.” Michael #2: Uvicorn adds multiprocess workers via John HagenThe goal was to no longer need to suggest that people use Gunicorn on top of uvicorn. Uvicorn can now in a sense "do it all”Steps to use it and background on how it works. Brian #3: pixi Suggested by Vic Kelson“pixi is a cross-platform, multi-language package manager and workflow tool built on the foundation of the conda ecosystem.”Tutorial: Doing Python development with PixiSome quotes from Vic: “Pixi is a project manager, written in Rust, that allows you to build Python projects without having Python previously installed. It’s installable with Homebrew (brew install pixi on Linux and MacOS). There’s support in VSCode and PyCharm via plugins. By default, pixi fetches packages from conda-forge, so you get the scientific stack in a pretty reliable and performant build. If a package isn’t on conda-forge, it’ll look on PyPI, or I believe you can force it to look on PyPI if you like.”“So far, it works GREAT for me. What really impressed me is that I got a Jupyter environment with CuPy utilizing my aging Nvidia GPU on the FIRST TRY.” Michael #4: JupyterLab 4.2 and Notebook 7.2 are available JupyterLab 4.2.0 has been released! This new minor release of JupyterLab includes 3 new features, 20 enhancements, 33 bug fixes and 29 maintenance tasks.Jupyter Notebook 7.2.0 has also been releasedHighlights include Easier Workspaces Management with GUIRecently opened/closed filesFull notebook windowing mode by default (renders only the cells visible in the window, leading to improved performance)Improved Shortcuts EditorDark High Contrast Theme Extras Brian: Help test Python 3.13!Help us test free-threaded Python without the GIL both from Hugo van KemenadePython Test 221: How to get pytest to import your code under test is out Michael: Bend follow up from Bernát Gábor “Bend looks roughly like Python but is nowhere there actually. For example it has no for loops, instead you're meant to use bend keyword (hence the language name) to expand calculations and another keyword to join branches. So basically think of something that resembles Python at high level, but without being compatible with that and without any of the standard library or packages the Python language provides. That being said does an impressive job at parallelization, but essentially it's a brand new language with new syntax and paradigms that you will have to learn, it just shares at first look similarities with Python the most.” Joke: Do-while
    Show more Show less
    21 mins
  • #385 RESTing on Postgres
    May 27 2024
    Topics covered in this episode: PostgresRESTHow Python Asyncio Works: Recreating it from ScratchBendThe Smartest Way to Learn Python Regular ExpressionsExtrasJokeExtrasJokeExtrasJokeWatch on YouTube About the show Sponsored by Mailtrap: pythonbytes.fm/mailtrap Connect with the hosts Michael: @mkennedy@fosstodon.orgBrian: @brianokken@fosstodon.orgShow: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 10am PT. Older video versions available there too. Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it. Michael #1: PostgresREST PostgREST serves a fully RESTful API from any existing PostgreSQL database. It provides a cleaner, more standards-compliant, faster API than you are likely to write from scratch.Speedy First the server is written in Haskell using the Warp HTTP server (aka a compiled language with lightweight threads). Next it delegates as much calculation as possible to the database.Finally it uses the database efficiently with the Hasql libraryPostgREST handles authentication (via JSON Web Tokens) and delegates authorization to the role information defined in the database. This ensures there is a single declarative source of truth for security. Brian #2: How Python Asyncio Works: Recreating it from Scratch Jacob PadillaCool tutorial walking through how async works, including Generators ReviewThe Event LoopSleepingYield to AwaitAwait with AsyncIOAnother great async resource is: Build your Own Async David Beasley talk from 2019 Michael #3: Bend A massively parallel, high-level programming language.With Bend you can write parallel code for multi-core CPUs/GPUs without being a C/CUDA expert with 10 years of experience. It feels just like Python!No need to deal with the complexity of concurrent programming: locks, mutexes, atomics... any work that can be done in parallel will be done in parallel. Brian #4: The Smartest Way to Learn Python Regular Expressions Christian Mayer, Zohaib Riaz, and Lukas RiegerSelf published ebook on Python Regex that utilizes book form readings, links to video course sectionspuzzle challenges to complete onlineIt’s a paid resource, but the min is free. Extras Brian: Replay - A graphic memoir by Prince of Persia creator Jordan Mechner, recounting his own family story of war, exile and new beginnings. Michael: PyCon 2026 Joke: Shells Scripts
    Show more Show less
    24 mins