Python Bytes

Follow Python Bytes
Share on
Copy link to clipboard

Python Bytes is a weekly podcast hosted by Michael Kennedy and Brian Okken. The show is a short discussion on the headlines and noteworthy news in the Python, developer, and data science space.

We know you're busy. Not everyone has time to scour social media platforms like Reddit or Twitter for Python developer news. When you subscribe, Python Bytes delivers easily-digestible headlines directly to you. Our weekly episodes bring you byte-sized chunks of tech news curated specifically for our discerning listeners. If you want a leg-up in the data and developing world, Python Bytes is a must-listen!

Michael Kennedy and Brian Okken

    • Mar 21, 2023 LATEST EPISODE
    • weekly NEW EPISODES
    • 31m AVG DURATION
    • 324 EPISODES

    4.8 from 182 ratings Listeners of Python Bytes that love the show mention: talk python, programming, brian, michael, news, community, show, world, thank, love, guys, great, work, always.

    Search for episodes from Python Bytes with a specific topic:

    Latest episodes from Python Bytes

    #328 We are going to need some context here

    Play Episode Listen Later Mar 21, 2023 24:48

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Show: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Brian #1: zipapp Part of standard library since 3.5 Yet another thing I learned recently from Brett Cannon “This module provides tools to manage the creation of zip files containing Python code, which can be executed directly by the Python interpreter. The module provides both a Command-Line Interface and a Python API.” Including: Creating Standalone Applications with zipapp Michael #2: Reverse engineering the Apple News app with #python and #nerd power As we navigate the digital world, we often come across articles we don't have time to read but still want to save for later. One way to accomplish this is by using the Read Later feature in Apple News. But what if you want to access those articles outside the Apple News app, such as on a different device or with someone who doesn't use Apple News? Or what if you want to automatically post links to those articles on your blog? That's where the nerd powers come in. The linked article shows how to use Python to solve your own problem Leading to Rhet Turnbull's CLI: apple-news-to-sqlite Brian #3: What is a context manager? Trey Hunner Also look at all the cool goodies in contextlib from standard library @contextmanager closing suppress redirect_stdout, redirect_stderr chdir Michael #4: nox-poetry: Use Poetry inside Nox sessions via 2 people: John Hagen and Marc Prewitt This package provides a drop-in replacement for the nox.session decorator, and for the nox.Session object passed to user-defined session functions. Comes from Claudio Jolowicz's hypermodern python cookiecutter Covered this on Talk Python: This session performs the following steps: Build a wheel from the local package. Install the wheel as well as the pytest package. Invoke pytest to run the test suite against the installation. Consider what would happen in this session if we had imported @session from nox instead of nox_poetry: Package dependencies would only be constrained by the wheel metadata, not by the lock file. In other words, their versions would not be pinned. The pytest dependency would not be constrained at all. Poetry would be installed as a build backend every time. Extras Brian: Sharing is Caring: Sharing pytest fixtures talk availabe at about 2:40:58 on Day 2 video of PyCascades 2023. Also full Day 1 and Day 2 Michael: Wired connection to remote mesh router == wow! Using the Linksys Atlas Max 6E Joke: UnsafeWarnings

    #327 Untangling XML with Pydantic

    Play Episode Listen Later Mar 13, 2023 31:37

    Watch on YouTube About the show Sponsored by Compiler Podcast from Red Hat. Connect with the hosts Michael: Brian: Show: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Michael #1: pydantic-xml extension via Ilan Recall untangle. How about some pydantic in the mix? pydantic-xml is a pydantic extension providing model fields xml binding and xml serialization / deserialization. It is closely integrated with pydantic which means it supports most of its features. Brian #2: How virtual environments work Brett Cannon This should be required reading for anyone learning Python. Maybe right after “Hello World” and right before “My first pytest test”, approximately. Some history of environments Back in the day, there was global and your directory. How environments work structure: bin, include, and lib pyvenv.cfg configuration file How Python uses virtual environments What activation does, and that it's optional. Yes, activation is optional. A new project called microvenv that helps VS Code. Mostly to fix the “Debian doesn't ship python3 with venv” problem. It doesn't include script activation stuff It's super small, less than 100 lines of code, in one file. Michael #3: DbDeclare Declarative layer for your database. Sent in by creator raaid DbDeclare is a Python package that helps you create and manage entities in your database cluster, like databases, roles, access control, and (eventually) more. It aims to fill the gap between SQLAlchemy (SQLA) and infrastructure as code (IaC). You can: Declare desired state in Python Avoid maintaining raw SQL Tightly integrate your databases, roles, access control, and more with your tables Migrations like alembic coming too. Brian #4: Testing multiple Python versions with nox and pyenv Seth Michael Larson This is a cool “what to do first” with nox. Specifically, how to use it to run pytest against your project on multiple versions of Python. Example is super small import nox @nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"]) def test(session): session.install(".") session.install("-rdev-requirements.txt")"pytest", "tests/") How to run everything, nox or nox -s test. How to run single sessions, nox -s test-311 for just Python 3.11 Also how to get this to work with pyenv. pyenv global 3.8 3.9 3.10 3.11 3.12-dev This reminds me that I keep meaning to write a workflow comparison post about nox and tox. Extras Michael: GitHub makes 2FA mandatory next week for active developers New adventure bike [image 1, image 2]. Who's got good ideas for where to ride in the PNW? Wondering why I got it, here's a fun video. Joke: Case of the Mondays

    #326 Let's Go for a PyGWalk

    Play Episode Listen Later Mar 8, 2023 33:26

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Show: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Brian #1: Data Classification : Does Python still have a need for class without @dataclass? Glyph dataclasses have been in the the language since 3.7 That's pretty much all modern Python, right? “…, is there any point to having non-@dataclass classes any more? Is there any remaining justification for writing them in new code?” Options: class just becomes a dataclass if you have typehinted members in it. data instead of class, to avoid decorators Michael #2: PyGWalker Turn your pandas dataframe into a Tableau-style User Interface for visual analysis. Works with pandas and polars Open-source alternative to Tableau It allows data scientists to analyze data and visualize patterns with simple drag-and-drop operations. Brian #3: An opinionated Python boilerplate Duarte O.Carmo Tools and processes for new projects pip-tools - Pip-tools strikes the right balance between simplicity, effectiveness, and speed. especially for generating pinned requirements.txt files, if necessary pyproject.toml - for configuration. packaging, but also any tool that supports it. ruff black, isort no pre-commit hooks, just run it in CI Michael #4: Front Matter VS Code via Mark Little If you have content that supports frontmatter and is markdown-based, check this out. Stay in your editor and easily create, manage, and publish content. Don't make front matter mistakes When was it published? What is the timezone text formatting again? Learn new features of your existing static site (e.g. article image) Manage images and more. Extras Brian: VSCode improves IntelliSense support for pytest in Feb release Michael: AI search wars get weird Proton Drive is Out of Beta, Available for Everyone Joke: Is your computer on? Is it on fire?

    #325 It's called a merge conflict

    Play Episode Listen Later Feb 28, 2023 39:32

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Show: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Michael #1: Python Parquet and Arrow: Using PyArrow With Pandas Parquet is an efficient, compressed, column-oriented storage format for arrays and tables of data. Less wrangle-able than Pandas, but way faster and lower memory Questions answered Can we use Pandas DataFrames and Arrow tables together, and if so, how is this done? (It turns out the answer is yes, and it's quite simple, as we'll see). In what ways are Arrow tables “better” than Pandas DataFrames? In other words, for which tasks are Arrow tables better suited? Conversely, what tasks are possible or easy in Pandas that are difficult or impossible in Arrow? As an on-disk format, how does Parquet compare to popular alternatives such as feather, orc, CSV, etc.? Brian #2: FastAPI-Filter Arthur Rio Add query string filters to your api endpoints and show them in the swagger UI. The supported backends are SQLAlchemy and MongoEngine. FastAPI-Filter documentation The philosophy of fastapi_filter is to be very declarative. You define the fields you want to be able to filter on as well as the type of operator, then tie your filter to a specific model. default filters: neq, gt, gte, in, isnull, lt, lte, not/ne, not_in, nin, like/ilike The swagger support is actually quite cool. Michael #3: 12 Python Decorators to Take Your Code to the Next Level Decorators are awesome This is mostly home-grown decorators, but some standard ones too Notable ones: @warps @lru_cache @repeat @timeit @retry ← no please use tenacity @countcall @rate_limited @dataclass @register @property @singledispatch Brian #4: PyHamcrest Contributed by Txels PyHamcrest is a framework for writing matcher objects, allowing you to declaratively define “match” rules. PyHamcrest tutorial Having a tool that allows you to pick out precisely the aspect under test and describe the values it should have, to a controlled level of precision, helps greatly in writing tests that are “just right.” From Brian: I've been reluctant to try matcher style assertion helper libraries, as, with pytest, assert works just fine. However, I can see cases where PyHamcrest assertions could help test readability, and that's always a win. Examples: equality: assert_that(theBiscuit, equal_to(myBiscuit)) exceptions: assert_that(calling(parse, bad_data), raises(ValueError)) async: assert_that(``**await** resolved(future), future_raising(ValueError)) boolean: assert_that(theBiscuit.isCooked()) There's predefined matchers for objects, numbers, text, logical checks, dequences, dictionaries Extras Brian: pytest tips and tricks - recent post, and discussion on upcoming Talk Python episode sharing pytest fixtures - placeholder page where I'll share slides and code after my talk. Michael: Python runtime updates Django 4.2 beta 1 released Joke: A group of developers is called …

    #324 JSON in My DB?

    Play Episode Listen Later Feb 21, 2023 44:53

    Watch on YouTube About the show Sponsored by Compiler Podcast from Red Hat. Connect with the hosts Michael: Brian: Show: Special guest, Erin Mullaney: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Brian #1: Use TOML for .env files? Brett Cannon .env files are used to store default settings that can be overridden by environmental variables. Possibly brought on by twelve-factor app design. Supported by python-dotenv, which is also used by pydantic, pipenv, and others. One issue is that it's not a defined standard. from python-dotenv docs “The format is not formally specified and still improves over time. That being said, .env files should mostly look like Bash files.” Adafruit decided that an upcoming CircuitPython will use TOML as the format for settings.toml files, which are to be used mostly how .env files are being used. Brett notices this may fix things for Python for VS Code, and other people as well. So… Is this a good idea? I think so. Michael #2: Pydantic gets serious funding via Mark Little (was on episode 285) Sequoia backs open source data-validation framework Pydantic to commercialize with cloud services. Pydantic Services Inc. emerges from stealth today with $4.7 million in seed funding. Pydantic's new commercial entity will incorporate a swath of new tools and services that are both “powered-by and inspired-by the Pydantic library” Pydantic will start with an initial team of six, with the first three engineers based in Montana, Chicago and Berlin. “With $4.7 million in the bank, Colvin said that they're continuing to rewrite parts of Pydantic in Rust, with a view toward making it more efficient via a ten-fold performance improvement.” Erin #3: JSON Fields for performance (Denormalization) David Stokes Using JSON fields when you design your databases is a good way to improve database query performance. Brian #4: f-strings with pandas and Jupyter keyboard shortcuts Kevin Markham After a couple year break from blogging, friend of the show Kevin Markham has a couple great, short, useful posts. How to use Python's f-strings with pandas My favorite bit is the part about using f-strings for dictionary keys Fly through Jupyter with keyboard shortcuts

    #323 AI search wars have begun

    Play Episode Listen Later Feb 14, 2023 50:05

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: - may be a minute or two late. Show: Special guest: Pamela Fox - Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Michael #1: camply A tool to find campsites at sold out campgrounds through sites like and Yellowstone Finding reservations at sold out campgrounds can be tough. Searches the APIs of booking services like (which indexes thousands of campgrounds across the USA) to continuously check for cancellations and availabilities to pop up. Once a campsite becomes available, camply sends you a notification to book your spot! Want to camp in a tower in California? camply campgrounds --search "Fire Lookout Towers" --state CA Brian #2: hatch-fancy-pypi-readme Your ✨Fancy✨ Project Deserves a ✨Fancy✨ PyPI Readme!

    #322 Python Packages, Let Me Count The Ways

    Play Episode Listen Later Feb 7, 2023 46:40

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Show: Special guest: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Brian #1: Packaging Python Projects Tutorial from PyPA This is a really good starting point to understand how to share Python code through packaging. Includes discussion of directory layout creating package files, LICENSE, pyproject.toml,, tests and src dir how to fill out build-system section of pyproject.toml using either hatchling, setuptools, flit, or pdm as backends metadata using build to generate wheels and tarballs uploading with twine However For small-ish pure Python projects, I still prefer flit flit init creates pyproject.toml and LICENSE will probably still need to hand tweak pyproject.toml flit build replaces build flit publish replaces twine The process can be confusing, even for seasoned professionals. Further discussion later in the show Michael #2: untangle xml Convert XML to Python objects Children can be accessed with parent.child, attributes with element['attribute']. Call the parse() method with a filename, an URL or an XML string. Given this XML: [HTML_REMOVED] [HTML_REMOVED] [HTML_REMOVED] [HTML_REMOVED] Access the document: obj.root.child['name'] # u'child1' A little cleaner that ElementTree perhaps. Calvin #3: Mypy 1.0 Released Mypy is a static type checker for Python, basically a Python linter on steroids Started in 2012 and developed by a team at Dropbox lead by What's New? New Release Numbering Scheme not using symver Significant backward incompatible changes will be announced in the blog post for the previous feature release feature flags will allow users to upgrade and turn on the new behavior Mypy 1.0 is 40% faster than 0.991 against the Dropbox internal codebase 20 optimizations included in this release Mypy now warns about errors used before definition or possibly undefined variables for example if a variable is used outside of a block of code that may not execute Mypy now supports the new Self type introduced in PEP 673 and Python 3.11 Support ParamSpec in Type Aliases Also, ParamSpec and Generic Self types are no loner experimental Lots of Miscellaneous New Features Fixes to crashes Support for compiling Python match statements introduced in Python 3.10 Brian #4: Thoughts on the Python packaging ecosystem Pradyun Gedam Some great background on the internal tension around packaging. Brian's note: in the meantime people are struggling to share Python code the “best practice” answer seems to shift regularly this might be healthy to arrive at better tooling in the long term, but in the short term, it's hurting us. From the article: The Python packaging ecosystem unintentionally became the type of competitive space that it is today. The community needs to make an explicit decision if it should continue operating under the model that led to status quo. Pick from N different tools that do N different things is a good model. Pick from N ~equivalent choices is a really bad user experience. Picking a default doesn't make other approaches illegal. Communication about the Python packaging ecosystem is fragmented, and we should improve that. Pradyun: “Many of the users who write Python code are not primarily full-time software engineers or “developers”.” from Thea: “The reason there are so many tools for managing Python dependencies is because Python is not a monoculture and different folks need different things.” opening up the build backend through pyproject.toml-based builds was good but the fracturing of multiple “workflow” tools seems bad. “I am certain that it is not possible to create a single “workflow” tool for Python software. What we have today, an ecosystem of tooling where each makes different design choices and technical trade-offs, is a part of why Python is as widespread as it is today. This flexibility and availability of choice is, however, both a blessing and a curse.” On building a default workflow tool around pip interesting idea There's tension between “we need a default workflow tool” and “unix philosophy: many focused tools that can work together”. Michael #5: Top PyPI Packages A monthly dump of the 5,000 most-downloaded packages from PyPI. Also, a full copy of PyPI info too: Calvin #6: SQLAlchemy 2.0 Released #57 on the Top PyPI Packages

    #321 A Memorial To Apps Past

    Play Episode Listen Later Jan 30, 2023 36:30

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Show: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Michael #1: git-sim Visually simulate Git operations in your own repos with a single terminal command. Generates an image (default) or video visualization depicting the Git command's behavior. Features Run a one-liner git-sim command in the terminal to generate a custom Git command visualization (.jpg) from your repo Supported commands: log, status, add, restore, commit, stash, branch, tag, reset, revert, merge, rebase, cherry-pick Generate an animated video (.mp4) instead of a static image using the --animate flag (note: significant performance slowdown, it is recommended to use --low-quality to speed up testing and remove when ready to generate presentation-quality video) Choose between dark mode (default) and light mode Animation only: Add custom branded intro/outro sequences if desired Animation only: Speed up or slow down animation speed as desired See images and animations on the github readme. Brian #2: Why I Like Nox Hynek Schlawack I like tox and have wanted to try nox but couldn't think of good reasons for a switch. Hynek is a fan of both, so it's nice to read his perspective. The article starts with comparing doing the same thing in both testing with Python 3.10 and 3.11 and adding the ability to pass in pytest arguments. even with this example, I do admit that the nox example is easier to read, but a bit more verbose. A second example of running a specific example combination of library and Python is quite a bit longer in nox, but there's an interesting commentary: “… this is longer than the tox equivalent. But that's because it's more explicit and anyone with a passing understanding of Python can deduce what's happening here – including myself, looking at it in a year. Explicit can be good, actually.” Other benefits: It's a Python file with Python functions, you have the all of Python at your disposal when developing sessions to run. It's not “ini format”. Complex ini files get out of hand quickly. nox has Python versions as fist class selectors. Final note: “Again, this article is not a call to abandon tox and move all your projects to Nox – I haven't done that myself and I don't plan to. But if my issues resonate with you, there's an option!” Michael #3: I scanned every package on PyPi and found 57 live AWS keys Scanning every release published to PyPi found 57 valid access keys. Detecting AWS keys is actually fairly simple. A keypair consists of two components: the key ID and the key secret. The key ID can be detected with the regular expression ((?:ASIA|AKIA|AROA|AIDA)([A-Z0-7]{16})) The secret key can be detected with a much more general [a-zA-Z0-9+/]{40}. Static PyPI data: Brian #4: Getting Started With Property-Based Testing in Python With Hypothesis and pytest Rodrigo Girão Serrão Hypothesis and property based testing can be overwhelming at first. So focused intro posts are quite helpful. This post focuses on a couple of examples, gcd(), greatest common divisor, and my_sort(), a custom list sorter. Good discussion of how property based testing is different and how to do it successfully, especially the order of development: focus on developing properties of correct answers develop a test that checks those properties use hypothesis strategies to come up with input pick @examples if necessary narrow the range of input if necessary caveat: I would have preferred hypothesis.assume() to limiting input in the first example. assume(not (n == m == 0)) see add more testing outside of hypothesis In my experience it's often easier for me to develop code with non-hypothesis test cases, then follow up with hypothesis. But after works also. The mental gymnastics of thinking of properties for algorithmic code is worthwhile. Extras Michael: First stream from the sweet new mac mini. Ivory released for Mastodon, but others too. Nice memorial We'll be doing a live in-person event at PyCon, become a friend of the show to get notified. Joke: Didn't come here to be called out

    #320 The Bug Is In The JavaScript

    Play Episode Listen Later Jan 24, 2023 28:26

    Watch on YouTube About the show Sponsored by us! Support our work through: Our courses at Talk Python Training Test & Code Podcast Patreon Supporters Connect with the hosts Michael: Brian: Show: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Brian #1: markdown-it-py Yes. another markdown parser. Rich recently switched markdown parsers, from commonmark to markdown-it-py. Let's look at those a bit. Michael #2: Sketch via Jake Firman Sketch is an AI code-writing assistant for pandas users that understands the context of your data A Natural Language interface that successfully navigates many tasks in the data stack landscape. Data Cataloging: General tagging (eg. PII identification) Metadata generation (names and descriptions) Data Engineering: Data cleaning and masking (compliance) Derived feature creation and extraction Data Analysis: Data questions Data visualization Watch the video on the GitHub page for a quick intro Brian #3: Fixing Circular Imports in Python with Protocol Built on Subclassing in Python Redux from Hynek We covered this in the summer of 2021, episode 240 However, I re-read it recently due to a typing problem Problem is when an object passes itself to another module to be called later. This is common in many design patterns, including just normal callback functions. Normally not a problem with Python, due to duck typing. But with type hints, suddenly it seems like both modules need types from the other. So how do you have two modules use types from each other without a circular import. Hynek produces two options Abstract Data Types, aka Interfaces, using the abc module Requires a third interface class Structural subtyping with Protocol This is what I think I'll use more often and I'm kinda in love with it now that I understand it. Still has a third type, but one of the modules doesn't have to know about it. "Structural Subtyping : Structural subtyping is duck typing for types: if your class fulfills the constraints of a [Protocol](, it's automatically considered a subtype of it. Therefore, a class can implement many Protocols from all kinds of packages without knowing about them!” The Fixing Circular Imports in Python with Protocol article walks through one example of two classes talking with each other, typing, circular imports, and fixing them with Protocol Michael #4: unrepl via/by Ruud van der Ham We've seen the code samples: >>> board = [] >>> for i in range(3): ... row = ['_'] * 3 ... board.append(row) ... >>> board [['_', '_', '_'], ['_', '_', '_'], ['_', '_', '_']] >>> board[2][0] = 'X' >>> board [['_', '_', '_'], ['_', '_', '_'], ['X', '_', '_']] But you cannot really run this code. You can't paste it into a REPL yourself nor can you put it into a .py file. So you unrepl it: Copying the above code to the clipboard and run unrepl. Paste the result and now you can. Unrepl can be used as a command line tool but also as a module. The REPL functionality of underscore (_) to get access to the last value is also supported. Extras Michael: You'll want to update your git ASAP. Get course releases at Talk Python via RSS Gist for using Turnstile with Python + Pydantic Joke: there's a bug in the js You've checked all your database indexes, You've tuned all your API hooks, You're starting to think That you might need a drink, Because there's only one place left to look: … There must be a bug in the javascript Because everything else was built properly But the frontend's a pile of crap ;)

    #319 CSS-Style Queries for... JSON?

    Play Episode Listen Later Jan 18, 2023 32:44

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Show: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Michael #1: Secure maintainer workflow by Ned Batchelder We are the magicians, but also the gatekeepers for our users Terminal sessions with implicit access to credentials first is unlikely: a bad guy gets onto my computer and uses the credentials to cause havoc second way is a more serious concern: I could unknowingly run evil or buggy code that uses my credentials in bad ways. Mitigations 1Password: where possible, I store credentials in 1Password, and use tooling to get them into environment variables. Side bar: Do not use lastpass, see end segment I can have the credentials in the environment for just long enough to use them. This works well for things like PyPI credentials, which are used rarely and could cause significant damage. Docker: To really isolate unknown code, I use a Docker container. Brian #2: Tools for parsing HTML and JSON Learned these from A Year of Writing about Web Scraping in Review Parsel - extract and remove data from HTML using XPath and CSS selectors jmespath - “James Path” - declaratively specify how to extract elements from a JSON document Michael #3: git-sizer Compute various size metrics for a Git repository, flagging those that might cause problems. Tip, partial clone: git clone --filter=blob:none URL # Stats for # Full: git clone repo Receiving objects: 100% (118820/118820), 514.31 MiB | 28.83 MiB/s, done. Resolving deltas: 100% (71763/71763), done. Updating files: 100% (10792/10792), done. 1.01 GB on disk # Partial: git clone --filter=blob:none repo Receiving objects: 100% (10120/10120), 220.25 MiB | 24.92 MiB/s, done. Resolving deltas: 100% (1454/1454), done. Updating files: 100% (10792/10792), done. 694.4 MB on disk Partial clone is a performance optimization that “allows Git to function without having a complete copy of the repository. The goal of this work is to allow Git better handle extremely large repositories.” When changing branches, Git may download more missing files. Not the same as shallow clones or sparse checkouts Consider shallow clones for CI/CD/deployment Sparse checkouts for a slice of a monorepo Brian #4: Dataclasses without type annotations Probably file this under “don't try this at home”. Or maybe “try this at home, but not at work”. Or just “that Brian fella is a bad influence”. What! It's not me. It's Adrian, the dude that wrote the article. Unless you're using a type checker, for dataclasses, “… use any type you want. If you're not using a static type checker, no one is going to care what type you use.” @dataclass class Literally: anything: ("can go", "in here") as_long_as: lambda: "it can be evaluated" # Now, I've noticed a tendency for this program to get rather silly. hell: with_("from __future__ import annotations") it_s: not even.evaluated it: just.has(to=be) * syntactically[valid] # Right! Stop that! It's SILLY! Extras Michael: LastPass story just keeps getting worse We will see problems in supply chains because of this too A whole 2 hour discussion diving into what I touched on: Got your new mac mini yet? Or MacBook Pro? Joke: Developer/maker, what's my purpose?

    #318 GIL, How We Will Miss You

    Play Episode Listen Later Jan 10, 2023 39:38

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with us Michael: Brian: Show: Join us on YouTube at to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Brian #1: PEP 703 - Making the GIL Optional in CPython Author: Sam Gross Sponsor: Łukasz Langa Draft status, but on Standards Track, targeting Python 3.12 Suggested by: Will Shanks “The GIL is a major obstacle to concurrency.” Especially for scientific computing. PEP 703 proposes adding a --without-gil build configuration to CPython to let it run code without the global interpreter lock and with the necessary changes needed to make the interpreter thread-safe. PEP includes several issues with GIL and sckikit-learn, PyTorch, Numpy, Pillow, and other numerically intensive libraries. Python's GIL makes it difficult to use modern multi-core CPUs efficiently for many scientific and numeric computing applications. There's also a section on how the GIL makes many types of parallelism difficult to express. Changes primarily in internals, and not much exposed to public Python and C APIs: Reference counting Memory management Container thread-safety Locking and atomic APIs Includes information on all of these challenges. Distribution C-API extension authors will need access to a --without-gil Python to modify their projects and supply --without-gil versions. Sam is proposing “To mitigate this, the author will work with Anaconda to distribute a --without-gil version of Python together with compatible packages from conda channels. This centralizes the challenges of building extensions, and the author believes this will enable more people to use Python without the GIL sooner than they would otherwise be able to.” Michael #2: FerretDB Via Jon Bultmeyer A truly Open Source MongoDB alternative MongoDB abandoned its Open-Source roots, changing the license to SSPL making it unusable for many Open Source and Commercial Projects. The core of our solution is a stateless proxy, which converts MongoDB protocol queries to SQL, and uses PostgreSQL as a database engine. FerretDB will be compatible with MongoDB drivers and will strive to serve as a drop-in replacement for MongoDB 6.0+. First release back in Nov 2022 I still love you MongoDB ;) Brian #3: Four tips for structuring your research group's Python packages David Aaron Nicholson Not PyPI packages, but, you know, directories with in them. Corrections for mistakes I see frequently Give your packages and modules terse, single-word names whenever possible. Import modules internally, instead of importing everything from modules. Make use of sub-packages. Prefer modules with very specific names containing single functions over modules with very general names like utils, helpers, or support that contain many functions. Michael #4: Quibbler Quibbler is a toolset for building highly interactive, yet reproducible, transparent and efficient data analysis pipelines. One import statement and matplotlib becomes interactive. Check out the video on the repo page. Extras Brian: And now for something completely different: turtles talk Michael: More RSS recommendations FreshRSS a self-hosted RSS and Atom feed aggregator. Feedly (for AI) Flym for Android Readwise is very interesting RSS for courses at Talk Python New article: Dev on the Road Joke: Testing the program Joke: Every Cloud Architecture

    #317 Most loved and most dreaded dev tools of 2022

    Play Episode Listen Later Jan 3, 2023 48:31

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Show: Michael #1: StackOverflow 2022 Developer Survey Last year we saw Git as a fundamental tool to being a developer. This year it appears that Docker is becoming a similar fundamental tool for Professional Developers, increasing from 55% to 69%. Language: Rust is […] the most loved language with 87% of developers saying they want to continue using it. JS Frameworks: Angular.js is in its third year as the most dreaded. Let me Google that for you: 62% of all respondents spend more than 30 minutes a day searching for answers or solutions to problems. 25% spending more than an hour each day. The demise of the full-stack developer is overrated. I do wish there were more women in the field. Databases: Postgres is #1 and MongoDB is still going strong. The “which web framework do you use?” question is a full on train wreck. Why is this so hard for people to write the question? Node.js or Express (built on Node) vs. FastAPI or Flask (but no Python?) Most wanted / loved language is Rust (wanted) and Python/Rust tied for most wanted. Worked with vs. want to work with has some interesting graphics. Brian #2: - PyPI download stats with package version breakdown Petru Rares Sincraian We've discussed before, which highlights daily downloads downloads per major/minor Python version downloads per OS PyPy is a bit more useful for me default shows last few versions and total for this major version “select versions” box is editable. clicking in it shows dropdown with downloads per version already there you can add * for graph of total or other major versions if you want to compare daily/weekly/monthly is nice, to round out some noise and see larger trends Oddity I noticed - daily graph isn't the same dates as the table. off by a day on both sides not a big deal, but I notice these kinds of things. Michael #3: Codon Python Compiler via Jeff Hutchins and Abdulaziz Alqasem A high-performance, zero-overhead, extensible Python compiler using LLVM You can scale performance and produce executables, even when using third party libraries such as matplotlib. It also supports writing and executing GPU kernels, which is an interesting feature. See how it works at BTW, really terrible licensing. Free for non-commercial (great) “Contact us” for commercial use (it's fine to charge, but give us a price) Brian #4: 8 Levels of Using Type Hints in Python Yang Zhou (yahng cho) A progression of using type hints that seems to track how I've picked them up Type Hints for Basic Data Types. x: int Define a Constant Using Final Type DB: Final = '``PostgreSQL' (ok. I haven't used this one at all yet) Adding multipe type hints to one variable. int | None Using general type hints. def func(nums: Iterable) Also using Optional Type hints for functions def func(name: str) → str: (I probably would put this at #2) Alias of type hints (not used this yet, but looks cool) PostsType = dict[int, str] new_posts: PostsType = {1: 'Python Type Hints', 2: 'Python Tricks'} Type hints for a class itself, i.e. Self type from typing import Self class ListNode: def __init__(self, prev_node: Self) -> None: pass Provide literals for a variable. (not used this yet, but looks cool) from typing import Literal weekend_day: Literal['Saturday', 'Sunday'] weekend_day = 'Saturday' weekend_day = 'Monday' # will by a type error Extras Brian: I hear a heartbeat for Test & Code, so it must not be dead yet. Michael: New article: Welcome Back RSS From this I learned about Readwise, Kustosz, and Python's reader. Year progress == 100% PyTorch discloses malicious dependency chain compromise over holidays (of course found over RSS and reeder — see article above) Joke: vim switch

    #316 Python 3.11 is here and it's fast (crossover)

    Play Episode Listen Later Dec 30, 2022 64:12

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Show announcements: Hi folks. For our final episode of 2022 here on Python Bytes, we're crossing the streams with my other show, Talk Python To Me. I present to you one of the more important episodes of the year, the release of Python 3.11 with it's new features and 40% performance improvements. Thank you for listening to Python Bytes in 2022, have a great holiday break, and Brian and I will see you next week. Python 3.11 is here! Keeping with the annual release cycle, the Python core devs have released the latest version of Python. And this one is a big one. It has more friendly error messages and is massively faster than 3.10 (between 10 to 60% faster) which is a big deal for a year over year release of a 30 year old platform. On this episode, we have Irit Katriel, Pablo Galindo Salgado, Mark Shannon, and Brandt Bucher all of whom participated in releasing Python this week on the show to tell us about that process and some of the highlight features. Guests Irit Katriel @iritkatriel Mark Shannon Pablo Galindo Salgado @pyblogsal Brandt Bucher Resources from the show Michael's Python 3.11 Course Python 3.11.0 is now available PEP 101 - Releasing Python PEP 678 – Enriching Exceptions with Notes PEP 654 – Exception Groups and except* PEP 657 – Include Fine Grained Error Locations in Tracebacks Python Buildbot Making Python Faster Talk Python Episode Specializing, Adaptive Interpreter on Talk Python Specialist Visualizer "Zero cost" exception handling Pyodide pyscript

    #315 Some Stickers!

    Play Episode Listen Later Dec 20, 2022 29:56

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Michael #1: Jupyter Server 2.0 is released! Jupyter Server provides the core web server that powers JupyterLab and Jupyter Notebook. New Identity API: As Jupyter continues to innovate its real-time collaboration experience, identity is an important component. New Authorization API: Enabling collaboration on a notebook shouldn't mean “allow everyone with access to my Jupyter Server to edit my notebooks”. What if I want to share my notebook with e.g. a subset of my teammates? New Event System API: jupyter_events—a package that provides a JSON-schema-based event-driven system to Jupyter Server and server extensions. Terminals Service is now a Server Extension: Jupyter Server now ships the “Terminals Service” as an extension (installed and enabled by default) rather than a core Jupyter Service. pytest-jupyter: A pytest plugin for Jupyter Brian #2: Converting to pyproject.toml Last week, episode 314, we talked about “Tools for rewriting Python code” and I mentioned a desire to convert to pyproject.toml Several of you, including Christian Clauss and Brian Skinn, let me know about a few tools to help in that area. Thank you. ini2toml - Automatically translates .ini/.cfg files into TOML “… can also be used to convert any compatible .ini/.cfg file to TOML.” “ini2toml comes in two flavours: “lite” and “full”. The “lite” flavour will create a TOML document that does not contain any of the comments from the original .ini/.cfg file. On the other hand, the “full” flavour will make an extra effort to translate these comments into a TOML-equivalent (please notice sometimes this translation is not perfect, so it is always good to check the TOML document afterwards).” pyproject-fmt - Apply a consistent format to pyproject.toml files Having a consistent ordering and such is actually quite nice. I agreed with most changes when I tried it, except one change. The faulty change: it modified the name of my project. Not cool. pytest plugins are traditionally named pytest-something. the tool replaced the - with _. Wrong. So, be careful with adding this to your tool chain if you have intentional dashes in the name. Otherwise, and still, cool project. validate-pyproject - Automated checks on pyproject.toml powered by JSON Schema definitions It's a bit terse with errors, but still useful. $ validate-pyproject pyproject.toml Invalid file: pyproject.toml [ERROR] `project.authors[{data__authors_x}]` must be object $ validate-pyproject pyproject.toml Invalid file: pyproject.toml [ERROR] Invalid value (at line 3, column 12) I'd probably add tox Don't forget to build and test your project after making changes to pyproject.toml You'll catch things like missing dependencies that the other tools will miss. Michael #3: aws-lambda-powertools-python Via Mark Pender A suite of utilities for AWS Lambda Functions that makes distributed tracing, structured logging, custom metrics, idempotency, and many leading practices easier Looks kinda cool if you prefer to work almost entirely in python and avoid using any 3rd party tools like Terraform etc to manage the support functions of deploying, monitoring, debugging lambda functions - Tracing: Decorators and utilities to trace Lambda function handlers, and both synchronous and asynchronous functions Logging - Structured logging made easier, and decorator to enrich structured logging with key Lambda context details Metrics - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF) Event handler: AppSync - AWS AppSync event handler for Lambda Direct Resolver and Amplify GraphQL Transformer function Event handler: API Gateway and ALB - Amazon API Gateway REST/HTTP API and ALB event handler for Lambda functions invoked using Proxy integration Bring your own middleware - Decorator factory to create your own middleware to run logic before, and after each Lambda invocation Parameters utility - Retrieve and cache parameter values from Parameter Store, Secrets Manager, or DynamoDB Batch processing - Handle partial failures for AWS SQS batch processing Typing - Static typing classes to speedup development in your IDE Validation - JSON Schema validator for inbound events and responses Event source data classes - Data classes describing the schema of common Lambda event triggers Parser - Data parsing and deep validation using Pydantic Idempotency - Convert your Lambda functions into idempotent operations which are safe to retry Feature Flags - A simple rule engine to evaluate when one or multiple features should be enabled depending on the input Streaming - Streams datasets larger than the available memory as streaming data. Brian #4: How to create a self updating GitHub Readme Bob Belderbos Bob's GitHub profile is nice Includes latest Pybites articles, latest Python tips, and even latest Fosstodon toots And he includes a link to an article on how he did this. A Python script that pulls together all of the content, and fills in a markdown file. It gets called through a GitHub action workflow, update.yml and automatically commits changes, currently daily at 8:45 This happens every day, and it looks like there are only commits if Note: We covered Simon Willison's notes on self updating README on episode 192 in 2020 Extras Brian: GitHub can check your repos for leaked secrets. Julia Evans has released a new zine, The Pocket Guide to Debugging Python Easter Eggs Includes this fun one from 2009 from Barry Warsaw and Brett Cannon >>> from __future__ import barry_as_FLUFL >>> 1 2 True >>> 1 != 2 File "[HTML_REMOVED]", line 1 1 != 2 ^ SyntaxError: invalid syntax Crontab Guru Michael: Canary Email AI 3.11 delivers First chance to try “iPad as the sole travel device.” Here's a report. Follow up from 306 and 309 discussions. Maps be free New laptop design Joke: What are clouds made of?

    #314 What are you, a wise guy? Sort it out!

    Play Episode Listen Later Dec 13, 2022 37:24

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Brian #1: FAQtory Will McGugan “FAQtory is a tool to auto-generate a (Frequently Asked Questions) document for your project. FAQtory has a written by itself, so you can see an example of the project in the project. Builds a markdown that includes questions at the top that link to answers below. “Additionally, a ‘suggest' feature uses fuzzy matching to reply to GitHub issues with suggestions from your FAQ.” I haven't tried this part, but looking forward to it. May help to answer GH issues that are really questions. Michael #2: Kagi search "live with it” report Still enjoying it a lot Very fast LOVE blocking SEO-heavy, content-light sites Maps are rough around the edges Not obvious how to set as a private/incognito search engine (but can be done in settings) They have browser extensions - but I don't want to install extensions I only use 1password & zoom It could use some documentation however (e.g. supports !'s, but what are they?) Being tempted by Orion too, but sticking with Vivaldi. Brian #3: Tools for rewriting Python code Luke Plant A collection of tools change your code (hopefully for the better) Several categories formatting and coding style - black, isort, … upgrades - pyupgrade, flynt, … we need one to convert from to pyproject.toml type hints - auto type hints? cool. maybe. I haven't tried any of these, but they look interesting refactoring, editors, rope, jedi other - autoflake, shed, … write your own, with LibCST Michael #4: Socketify Bringing WebSockets, Http/Https High Performance servers for PyPy3 and Python3 A new record for Python no other Web Framework as able to reach 6.2 mi requests per second before in @TFBenchmarks

    #313 Programming Robots With a Marker

    Play Episode Listen Later Dec 6, 2022 46:00

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Special guest: Kelly Schuster-Paredes Special guest: Sean Tibor Michael #1: How do you say that number? Inflect: Num2Words: # Inflect: import inflect inflector=inflect.engine() print(inflector.number_to_words(8675309)) # eight million, six hundred and seventy-five thousand, three hundred and nine # Num2Words from num2words import num2words print(num2words(8675309)) # eight million, six hundred and seventy-five thousand, three hundred and nine Num2Words also has a CLI: pipx install num2words $ num2words 2948475 two million, nine hundred and forty-eight thousand, four hundred and seventy-five Brian #2: The Origins of Python Lambert Meertens A wonderful tale starting with TELCOMP, traveling through ABC, and finally reaching Python. This is a long article, but a wonderful story. It includes a nice emphasis at all times to keep a language simple enough for the absolute beginner but powerful enough to not be annoying for experienced developers. A few quotes from the article: “Ease of learning and ease of use are both desirable attributes in any programming language. Nonetheless, I have often felt that this aspect of language design does not always receive the attention it deserves. And what may seem easy to a designer may not necessarily be easy for a language learner.” Regarding ABC: “To serve our intended users, absolute beginners, we sought to hide low-level implementation details and instead to provide powerful high-level, task-oriented features. Then Python: “The growth in popularity of Python, from its inception thirty years ago as a one-person effort flying under the radar, has been phenomenal, but not meteoric. Instead it has been a long, slow, and steady rise. Python's ease of learning gave it a competitive advantage in a period when there was a perpetual need for more programmers. Its clean syntax and semantics make it easier to maintain a software base written in Python than other languages—an important consideration given that the cost of maintaining software dwarfs the cost of creating new software.” Kelly #3: Ozobot Evo Introduces a Python Beta Version. (August 17, 2022) The original Ozobot model – the Ozobot Bit – is no longer available for purchase . The New Evo Ozobit- has three Kit options. The Entry Kit (single robot), the Ozobot Evo 12-Pack, and the Ozobot Evo 18-Pack. Still has the updated OzoBlockly platform for Block Programming. This tiny bot comes with: Line following Color detection Sound proximity sensor bluetooth Crash detection Students can even code functions Ozobot simulator(block) Web beta app: Michael #4: setproctitle A Python module to customize the process title Awesome for servers and anytime “python” is not enough Easy to use directly: from setproctitle import setproctitle setproctitle("tp-search daemon") Used automatically by servers like uwsgi and gunicorn I believe. ### # uWSGI server configuration ### [uwsgi] # uWSGI provides some functionality which can help identify the workers procname-prefix = training- auto-procname = true Some nice results, example from Talk Python Training Brian #5: Looking forward to Python 3.12 New features in 3.12a2 Improved Error Messages lots of other goodies, like pathlib.walk(). Release scheduled for Oct 2023 But why wait? Start testing your projects with it now: Testing with Python 3.12 Note that “During the alpha phase, features may be added up until the start of the beta phase (2023-05-08) and, if necessary, may be modified or deleted up until the release candidate phase (2023-07-31). Please keep in mind that this is a preview release and its use is not recommended for production environments.” Actually, with that note, you might want to wait. I don't. I'll deal with it when/if I get a failure. Sean #6: Re:Invent 2022 EF Education Breakout Presentation at AWS Re:Invent 2022 Complete redesign of online learning platform by one of the largest education companies in the world We've all seen Zoom classrooms with rows on rows of students A more immersive experience for learning with green screens, digital sets, and props Massive amount of analytics around student engagement and learning, including full transcription of every student, engagement tracking, and computer vision Extras Michael: You can support the PSF if you're selling things on EBay. Check “Donate a portion to charity” and choose “Python Software Foundation” via Joe Riedley Textinator for Windows (the Windows version of TextSniper) Paperlike for iPad Kelly: A new Special Interest Group for the PSF launched 6 days ago. “Edu-sig, through its mailing list, provides an informal venue for comparing notes and discussing future possibilities for Python in education.” Led by Timothy Wilson. Sean: Dr. Werner Vogel's keynote - everything is coming up async EventBridge Pipes Jokes: And a new mastodon user:

    #312 AI Goes on Trial For Writing Code

    Play Episode Listen Later Nov 29, 2022 35:26

    Watch on YouTube About the show Sponsored by Complier Podcast from RedHat Connect with the hosts Michael: Brian: Brian #1: Coping strategies for the serial project hoarder Simon Willison Also a talk from DjangoCon2022 Massively increase your productivity on personal projects with comprehensive documentation and automated tests. I'm actually not sure what title would be best, but this is an incredible video that I'm encouraging every developer to watch, whether or not you work with open source projects. Covers The perfect commit Implementation, Tests, Documentation, and a link to an issue thread Tests Prove the implementation works, pass if it works, fails otherwise A discussion of how adding tests is way easier than starting testing a project, so get the framework in place early, and devs won't be afraid to add to it. Cookiecutter repo templates for projects you will likely start super cool idea to have your own that you keep up to date with your preferred best practices A trick for using GitHub actions to use those templates to populate new repos Trying this out is on my todo list Documentation must live in the same repo as the code and be included in PRs for the PR to be accepted by code review maybe even test this using documentation unit tests Everything links to an issue thread Keep all of your thoughts in an issue thread Doesn't have to be a dialog with anyone but yourself This allows you to NOT HAVE TO REMEMBER ANYTHING Tell people what you did This is just as important in work projects as it is in open source Blog about it Post on Twitter (or Mastodon, etc.) Avoid side projects with user accounts “If you build something that people can sign into, that's not a side-project, it's an unpaid job. It's a very big responsibility, avoid at all costs!” - this is hilarious and something I'm probably not going to follow Michael #2: GitHub copilot lawsuit First, we aren't lawyers Lawsuit filed on November 3, 2022 We've filed a lawsuit challenging GitHub Copilot, an AI product that relies on unprecedented open-source software piracy. GitHub copilot is trained on projects on GitHub, including GPL and other restrictive licenses This is the first class-action case in the US challenging the training and output of AI systems. Brian #3: Use Windows Dialog Boxes from Python with no extra libraries Actual title: Display a message box with Python without using a non-standard library or other dependency (Windows) By Matt Callahan / learned about from from PyCoders weekly When I need a simple pop up dialog box that's cross platform, PySimpleGUI is awesome and so easy. But when I KNOW it's only going to run on Windows, why not just use native dialog boxes? Matt's article shows you how, using ctypes to call into a Windows dll. Small example from article: import ctypes def main(): WS_EX_TOPMOST = 0x40000 windowTitle = "Python Windows Message Box Test" message = "Hello, world!" # display a message box; execution will stop here until user acknowledges ctypes.windll.user32.MessageBoxExW(None, message, windowTitle, WS_EX_TOPMOST) print("User clicked OK.") if __name__ == "__main__": main() Notes: The uType (fourth) parameter is a multi-use value that can be or-ed for things like: Type of dialog box: Help, OK, OK/Cancel, Retry/Cancel, Yes/No, etc. The icon to use: Exclamation, Info, Question, etc. Modality, … Return value is used to understand how user reacted: 1 - OK, 2 - Cancel (or x), …, 6 - Yes, 7 - No, … Michael #4: Extra Extra Extra Python browser extensions takahe - Mastodon on Python - the right way Michael's article in Black Friday perf We could scale down our server after what I've learned. But we'd pay 10x more in bandwidth overages ironically: Last month Talk Python broadly transferred 20.2 TB of data from our servers Moved our static traffic to Bunny CDN, highly recommended service RSS revival My blog: Reeder 5 app on iOS and macOS Rivers Cuomo (from Weezer) and Guido sit down for a talk together Also check out the Talk Python episode with Rivers: Kite is saying farewell

    #311 Catching Memory Leaks with ... pytest?

    Play Episode Listen Later Nov 24, 2022 49:50

    Watch on YouTube About the show Python Bytes 311 Sponsored by Microsoft for Startups Founders Hub. Connect with the hosts Michael: Brian: Special guest: Murilo Cunha Michael #1: Latexify We are used to turning beautiful math into programming symbols. For example: Take this code: def do_math(a, b, c): return (-b + math.sqrt(b ** 2 - 4 * a * c)) / (2 * a) Add @latexify.function decorator display do_math in a notebook Get this latex: mathrm{do_math}(a, b, c) = frac{-b + sqrt{b^{{2}} - {4} a c}}{{2} a} Which renders as I could only get it to install with: pip install git+ Brian #2: prefixed From Avram Lubkin “Prefixed provides an alternative implementation of the built-in float which supports formatted output with SI (decimal) and IEC (binary) prefixes.” >>> from prefixed import Float >>> f'{Float(3250):.2h}' '3.25k' >>> '{:.2h}s'.format(Float(.00001534)) '15.34μs' >>> '{:.2k}B'.format(Float(42467328)) '40.50MiB' >>> f'{Float(2048):.2m}B' '2.00KB' Because prefixed.Float inherits from the built-in float, it behaves exactly the same in most cases. When a math operation is performed with another real number type (float, int), the result will be a prefixed.Float instance. also interesting First new SI prefixes for over 30 years new prefixes also show up here - Murilo #3: dbt Open source tool CLI tool Built with Python

    #310 Calling All Tools for Readmes

    Play Episode Listen Later Nov 15, 2022 53:44

    Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Special guest: Adam Hopkins Python Web Development with Sanic Brian #1: Tips for clean code in Python Bob Belderbos Generally some great tips to think about to keep code maintainable: Smaller units. Break things up into single responsibility. SRP: Single Responsibility Principle Move magic numbers into constants or parameters. Avoid global scope. (even though it's not really global) Use linters and auto-formatters. Use very narrow try/except blocks. Idiomatic Python. (Although I agree, this is a weird one as it's hard for new people to follow). Pay attention to data structure choice and learn to utilize standard structures and those in collections. Use the standard libary. Use mappings Flat is better than nested. But I'm gonna focus on the “smaller units” because it applies to modules as well. Try to keep modules organized such that you can keep relevant and related code concepts in your head. Michael #2: Mastodon is picking up speed I'm calling this a “Mastodon First” strategy rather than “Let's burn down Twitter and scatter” Just did a Talk Python about it Money in mouth: I became a patreon of Fosstodon and Mastodon's company Mastodon is open source, find it here Twitter's potential collapse could wipe out vast records of recent human history Python's API for Mastodon: toot Download a proper Twitter archive with this Python script Integrated the API into stream deck You can install it as a PWA: Adam #3: Correction to Sanic Worker Manager in v22.9 Episode #308 covered a recent article published on a new feature in Sanic v22.9 Blog article: Pushing work to the background of your Sanic app The segment focused on the celery-like job queue in Sanic Clarification: Goal of the feature is to bring a consistent development experience from dev thru prod Enables usage of multiprocessing-safe shared objects Simple pattern for managing multiple long-running processes Release notes for Sanic v22.9 Sanic documentation on the Worker Manager Brian #4: Some FastAPI news, and some great READMEs. FastAPI 0.87.0 has some interesting notes Upgraded Starlette, which includes TestClient based on HTTPX instead of Requests Since that might break some peoples use of TestClient, someone named Kludex built bump-testclient to help automatically convert test code to the new interface. That's so cool! Use Ruff for linting Add a Help Maintain FastAPI section to the docs that emphasizes that it's super helpful to: Help others with issues Review PRs Both of those sections have other expanded sections to describe what that means. The FastAPI commitment to great documentation is amazing and worth emulating. It also has a really good README. Interesting sponsors section. Cool way for a popular project to get maintenance funding. Testimonials. It's like a sales landing page, which really, a README kinda is. Other common good practices and cool items Images Some use of collapsable sections. Other notable READMEs pytest short example right away to show how simple it can be to use. textual and rich great use of images and short examples highlighting often missed features, such as pretty and inspect Utilizing expandable/collapsable sections for longer examples httpx like pytest, shows a small example quickly, redirects many other sections to more thorough docs. Michael #5: Closevember An annual event focused on sustainable open source development practices and maintainer well-being. Let's support open source maintainers by helping them close issues and pull requests throughout November. Over at Contributing to a project carries a number of responsibilities, in order to make it as easy as possible for a project to receive that contribution. For Maintainers: How to Get Ready (see site) If you only want assistance with closing some issues and PRs, then tag your repo with closember and you're all set. One thing that we often find helpful is to declutter our physical and digital environment: tidying our desks a bit, decluttering our computers' desktops, unsubscribing from some email lists ... that sort of thing. I did this this month actually. Spent 6 hours completely rebuilding my desk to have zero wires and look tidy and clean (hint: 3m of industrial velcro and things stuck upside down) and formatted my computer to a fresh OS after two years. For the Community: How to Participate (see site) If you've never used GitHub before, your first step is going to be signing up for a free account. Also, if you're super new to git: If you've opened issues or PRs on projects in the past, you can start by taking a look at your own GitHub issues and your own PRs to see if any of them are outdated or have already been fixed—if so, close them! After that, start browsing projects: take a look at your favorite projects and see if they've been tagged with closember, or browse the list of closember projects. Check out the close boards (on the site) Adam #6: Super simple “Cache with async power” using Cashews Recently popped up in my GitHub Explore Cashews: Async cache framework with simple API to build fast and reliable applications Super simple out-of-the-box API supports in memory, Redis, DiskCache (local sqlite) one-line setup then implemented as a decorator Human-friendly TTL values: example “3h” Client-side caching - For example, if you are using Redis backend you do not need to make a network call on every cache request Strategies for common cache issues cache hits, early recalculation, soft TTL, resource locking, rate limiting!, circuit breaker Has its own interface for middleware Extras Michael: Take the PSF survey Adam: Voting season is upon us: Python Steering Council nominations are open Joke: JavaScript has been Banned from Twitter

    #309 When Malware PoC's are Themselves Malware

    Play Episode Listen Later Nov 9, 2022 35:01

    #308 Conference season is heating up

    Play Episode Listen Later Nov 1, 2022 34:37

    Watch the live stream: Watch on YouTube About the show Sponsored by Complier Podcast from RedHat Michael #0: New livestream time - 11am PT on Tuesdays. Also, subscribe to the youtube channel and “hit the bell” to get notified of all the live streams. Brian #1: It's PyCon US 2023 CFP time Will be held in Salt Lake City, Salt Palace Convention Center Talks are Friday - Sunday, April 19-23 PyCon US 2023 launch announcement PyCon 2023 site features images taken from past PyCon artwork Call for proposals open until Dec 9, but please don't wait that long. Michael #2: AnyIO is an asynchronous networking and concurrency library that works on top of either asyncio or trio. It implements trio-like structured concurrency (SC) on top of asyncio. Cool interpretability between native threads and asyncio Using subprocesses: AnyIO allows you to run arbitrary executables in subprocesses, either as a one-shot call or by opening a process handle for you that gives you more control over the subprocess. Async file I/O: AnyIO provides asynchronous wrappers for blocking file operations. These wrappers run blocking operations in worker threads. Cool synchronization primitives too. Catch the Talk Python episode with Alex: Brian #3: How to propose a winning conference talk Reuven Lerner Some nice tips and advice Build a list of topics If you train, teach, mentor, lead, or coach already: what questions to people always ask you? what knowledge would help people to have? where do people seem to just “not get it”? If you don't train or teach, then maybe hit up Stack Overflow… From Brian: I think you can imagine yourself a year or two ago and think about stuff you know now you wish you knew then and could learn faster. Build an outline with times This part often seems scary, but Reuven's example is 10 bullets with (x min) notes. Write up a summary. One short, one longer. Indicate who will benefit, what they will come out knowing, and how it will help them. Propose to multiple conferences. Why not? Practice (from Brian: Even if you get rejected, you've gained. Turn it into a youTube video or blog post or both.) - Michael #4: Sanic release adds background workers via Felix In v22.9 (go cal-ver!), the main new feature is the worker process management - the main Sanic process handles a pool of workers. They are normally used for handling requests but you can also use them to handle background jobs and similar things. You could probably use it for a lot of the reasons people turn to something like Celery. The lead developer (Adam Hopkins) has written a blog post about this feature. MK: Sanic has been flying a bit under my radar. Maybe time to dive into it a bit more. Extras Brian: Create Presentation from Jupyter Notebook Cool walkthrough of how to use the built in slideshow features of Jupyter Notebooks. pytest 7.2.0 is out No longer depends on the py library. So if you do, you need to add it to your dependencies. nose officially deprecated, which includes setup() and teardown(). Really glad I dropped the “x unit” section on the 2nd edition of the pytest book. testpaths now supports shell-style wildcards Lots of other improvements. check out the change log Michael: Rich on pyscript (via Matt Kramer) Python 3.11 in 100 seconds video from Michael Joke: Deep questions & Relationship advice from geeks