Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book

#294: Specializing Adaptive Interpreters in Full Color

Published Tue, Jul 26, 2022, recorded Wed, Jul 13, 2022

Watch the live stream:

Watch this episode on YouTube
Play on YouTube
Watch the live stream replay

About the show

Sponsored by Microsoft for Startups Founders Hub.

Michael #1: Specialist: Python 3.11 perf highlighter

  • via Alex Waygood
  • Visualize CPython 3.11's specializing, adaptive interpreter. 🔥
  • PEP 659 – Specializing Adaptive Interpreter
  • Specialist uses fine-grained location information to create visual representations of exactly where and how CPython 3.11's new specializing, adaptive interpreter optimizes your code.
  • Dark, rich colors indicate code with many quickened instructions (and, therefore, high specialization potential), while light, pale colors indicate code with relatively few specialization opportunities.

Brian #2: tomli “A lil’ TOML parser”

  • Fully compatible with TOML spec 1.0.0
  • This is the library that tomllib from Python 3.11 is based on, so great to use for Python 3.7-3.10 applications.
  • Real Python has a great introduction for TOML in Python: Python and TOML: New Best Friends
    • TOML as a config format, key-value pairs, data types
    • using both tomli and tomllib
    • Loading TOML documents into Python
    • And like, writing, and updating toml docs programatically, which, although cool, I think the bulk of users can kinda skip over. But the the first 3 sections are an excellent reference.
    • Tables are cool, with [name] and [name.subsection] syntax, as well as arrays of tables with [[name]] syntax. I didn’t know how to do that before this article.

Michael #3: Pydantic V2 Plan

Brian #4: pikepdf

  • a Python library for reading and writing PDF files
  • Based on QPDF, which is written in C++.
  • Features:
    • Supports password protected PDFs
    • Creates linearized ("fast web view") PDFs
    • Integrates with Jupyter and IPython notebooks for rapid development
  • Some cool uses
    • copy pates from one PDF into another
    • split and merge PDFs
    • extract content
    • replace content, such as replacing images, without altering the rest of the file.
  • Documentation mentions that if you only want to write PDFs, consider other libs, such as reportlab.

Extras

Brian:

  • pytest-check
    • I’ve set up 2fa for my account, so now I have no excuse for not looking into feature requests and merge requests for pytest-check, other than like all the other things I’m doing.
    • I don’t have data for the top 3,500 for the last 6 months, but there is a list of the top 5,000 for last 30 days.
    • pytest-check is #1677 in the last 30 days.
    • pytest is #72 on the same list.
    • pydantic is #117
    • There are 57 pytest plugins that show up in the top 3,500 python packages. (packages that start with “pytest-”)
    • pytest-check is #20 of those. I guess it’s time to do another top plugins episode of Test & Code.

Joke:


Want to go deeper? Check our projects