Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22466

Python Bytes: #294 Specializing Adaptive Interpreters in Full Color

$
0
0
<p><strong>Watch the live stream:</strong></p> <a href='https://www.youtube.com/watch?v=dQgR4Bu9ixQ' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>About the show</strong></p> <p>Sponsored by <a href="http://pythonbytes.fm/foundershub2022"><strong>Microsoft for Startups Founders Hub</strong></a>.</p> <p><strong>Michael #1:</strong> <a href="https://github.com/brandtbucher/specialist"><strong>Specialist: Python 3.11 perf highlighter</strong></a></p> <ul> <li>via Alex Waygood</li> <li>Visualize CPython 3.11's specializing, adaptive interpreter. 🔥</li> <li><a href="https://peps.python.org/pep-0659/"><strong>PEP 659 – Specializing Adaptive Interpreter</strong></a></li> <li>Specialist uses <a href="https://peps.python.org/pep-0657/">fine-grained location</a> information to create visual representations of exactly <em>where</em> and <em>how</em> CPython 3.11's new <a href="https://peps.python.org/pep-0659/">specializing, adaptive interpreter</a> optimizes your code.</li> <li>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.</li> </ul> <p><strong>Brian #2:</strong> <a href="https://pypi.org/project/tomli/"><strong>tomli “A lil’ TOML parser”</strong></a></p> <ul> <li>Fully compatible with TOML spec 1.0.0</li> <li>This is the library that tomllib from Python 3.11 is based on, so great to use for Python 3.7-3.10 applications. <ul> <li>We discussed Python 3.11 and PEP 680 on <a href="https://pythonbytes.fm/episodes/show/273/getting-dirty-with-eq-self-other">episode 273</a></li> </ul></li> <li>Real Python has a great introduction for TOML in Python: <a href="https://realpython.com/python-toml/">Python and TOML: New Best Friends</a> <ul> <li>TOML as a config format, key-value pairs, data types</li> <li>using both tomli and tomllib</li> <li>Loading TOML documents into Python</li> <li>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.</li> <li>Tables are cool, with <code>[name]</code> and <code>[name.subsection]</code> syntax, as well as arrays of tables with <code>[[name]]</code> syntax. I didn’t know how to do that before this article.</li> </ul></li> </ul> <p><strong>Michael #3:</strong> <a href="https://pydantic-docs.helpmanual.io/blog/pydantic-v2/"><strong>Pydantic V2 Plan</strong></a></p> <ul> <li>via <a href="https://twitter.com/TheNickleMan/status/1546455211350392832"><strong>Douglas Nichols</strong></a> and John Thagen</li> <li>A very detailed plan</li> <li>Goal to have all this done by the end of October, definitely by the end of the year.</li> <li>Samuel Colvin take a sabbatical to work on this (sound familiar?)</li> <li>Some details highlighted by John: <ul> <li>Moving the core logic to Rust to drastically increase performance (17x) <a href="https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#performance">https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#performance</a></li> <li>Strict mode (something I've wanted for a long time): <a href="https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#strict-mode">https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#strict-mode</a></li> <li>Cleaning up required vs nullable: <a href="https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#required-vs-nullable-cleanup">https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#required-vs-nullable-cleanup</a></li> <li>Naming cleanup: <a href="https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#model-namespace-cleanup">https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#model-namespace-cleanup</a></li> </ul></li> <li>This is a huge change, but overall it looks very promising for the community. It will likely require refactors by downstream users, so pinning pydantic using Poetry/pip-tools etc like always is a good idea.</li> <li>Many things have Pydantic at the core, so this matters, including: <ul> <li>FastAPI</li> <li>Beanie</li> <li>SQLModel</li> <li>Pydastic</li> <li>…</li> </ul></li> </ul> <p><strong>Brian #4:</strong> <a href="https://github.com/pikepdf/pikepdf"><strong>pikepdf</strong></a></p> <ul> <li>a Python library for reading and writing PDF files</li> <li>Based on QPDF, which is written in C++.</li> <li>Features: <ul> <li>Supports password protected PDFs</li> <li>Creates linearized ("fast web view") PDFs</li> <li>Integrates with Jupyter and IPython notebooks for rapid development</li> </ul></li> <li>Some cool uses <ul> <li>copy pates from one PDF into another</li> <li>split and merge PDFs</li> <li>extract content</li> <li>replace content, such as replacing images, without altering the rest of the file.</li> </ul></li> <li>Documentation mentions that if you only want to write PDFs, consider other libs, such as reportlab.</li> </ul> <p><strong>Extras</strong> </p> <p>Brian:</p> <ul> <li>pytest-check <ul> <li>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. </li> <li>I don’t have data for the top 3,500 for the last 6 months, but there is a list of the <a href="https://hugovk.github.io/top-pypi-packages/">top 5,000 for last 30 days</a>.</li> <li>pytest-check is #1677 in the last 30 days.</li> <li>pytest is #72 on the <a href="https://hugovk.github.io/top-pypi-packages/">same list</a>.</li> <li>pydantic is #117</li> <li>There are 57 pytest plugins that show up in the top 3,500 python packages. (packages that start with “pytest-”)</li> <li>pytest-check is #20 of those. I guess it’s time to do another top plugins episode of Test &amp; Code.</li> </ul></li> </ul> <p><strong>Joke:</strong> </p> <ul> <li><a href="https://mobile.twitter.com/NetaCodeGirl/status/1522193850323935233"><strong>Error, OK, I’ll check the logs</strong></a></li> </ul>

Viewing all articles
Browse latest Browse all 22466

Trending Articles