POPULARITY
AI is helping people write code. Tests are one of those things that some people don't like to write. Can AI play a role in creating automated software tests? Well, yes. But it's a nuanced yes. Anthony Shaw comes on the show to discuss the topic and try to get AI to write some test for my very own cards project.We discuss:The promise of AI writing your tests for youDownsides to not writing tests yourselfBad ways to generate testsGood ways to ask AI for help in writing testsTricks to get better results while using copilot and other AI toolsLinks:The cards projectA video version of this discussion: Should AI write tests? Sponsored by: Porkbun -- named the #1 domain registrar by USA Today from 2023 to 2025!Get a .app or.dev domain name for only $5.99 first year.Learn pytest: The Complete pytest course is now a bundle, with each part available separately.pytest Primary Power teaches the super powers of pytest that you need to learn to use pytest effectively.Using pytest with Projects has lots of "when you need it" sections like debugging failed tests, mocking, testing strategy, and CIThen pytest Booster Rockets can help with advanced parametrization and building plugins.Whether you need to get started with pytest today, or want to power up your pytest skills, PythonTest has a course for you. ★ Support this podcast on Patreon ★
Talk Python To Me - Python conversations for passionate developers
If you are a .NET developer or work in a place that has some of those folks, wouldn't it be great to fully leverage the entirety of PyPI with it's almost 600,000 packages inside your .NET code? But how would you do this? Previous efforts have let you write Python syntax but using the full libraries (especially the C-based ones) has been out of reach, until CSnakes. This project by Anthony Shaw and Aaron Powell unlocks some pretty serious integration between the two languages. We have them both here on the show today to tell us all about it. Episode sponsors Posit Bluehost Talk Python Courses Links from the show Anthony Shaw: github.com Aaron Powell: github.com Introducing CSnakes: tonybaloney.github.io CSnakes: tonybaloney.github.io Talk Python: We've moved to Hetzner: talkpython.fm/blog Talk Python: Talk Python rewritten in Quart (async Flask): talkpython.fm/blog Pyjion - A JIT for Python based upon CoreCLR: github.com Iron Python: ironpython.net Python.NET: pythonnet.github.io The buffer protocol: docs.python.org Avalonia UI: avaloniaui.net Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Mastodon: talkpython Follow Michael on Mastodon: mkennedy
Topics covered in this episode: Python 3.13.0 released Oct 7 PEP 759 – External Wheel Hosting pytest-freethreaded pytest-edit Extras Joke Watch on YouTube About the show Sponsored by ScoutAPM: pythonbytes.fm/scout Connect with the hosts Michael: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday 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: Python 3.13.0 released Oct 7 That's today! What's New In Python 3.13 Interpreter (REPL) improvements exit works (really, this is worth the release right here) Multiline editing with history preservation. history sticks around between sessions Direct support for REPL-specific commands like help, exit, and quit, without the need to call them as functions. Prompts and tracebacks with color enabled by default. Interactive help browsing using F1 with a separate command history. History browsing using F2 that skips output as well as the >>> and … prompts. “Paste mode” with F3 that makes pasting larger blocks of code easier (press F3 again to return to the regular prompt). exit now works without parens Improved error messages Colorful tracebacks Better messages for naming a script/module the same name as a stdlib module. naming a script/module the same name as an installed third party module. misspelling a keyword argument Free threaded CPython Included in official installers on Windows and macOS Read these links to figure out how - it's not turned on by default Lot's more. see the What's new page Michael #2: PEP 759 – External Wheel Hosting pypi.org ships over 66 petabytes / month backed by Fastly There are hard project size limits for publishers to PyPI We can host the essence of a .whl as a .rim file, then allow an external download URL Security: Several factors as described in this proposal should mitigate security concerns with externally hosted wheels, such as: Wheel file checksums MUST be included in .rim files, and once uploaded cannot be changed. Since the checksum stored on PyPI is immutable and required, it is not possible to spoof an external wheel file, even if the owning organization lost control of their hosting domain. Externally hosted wheels MUST be served over HTTPS. In order to serve externally hosted wheels, organizations MUST be approved by the PyPI admins. Brian #3: pytest-freethreaded PyCon JP 2024 Team: This extension was created at PyCon JP sprints with Anthony Shaw and 7 other folks listed in credits. “A pytest plugin for helping verify that your tests and libraries are thread-safe with the Python 3.13 experimental freethreaded mode.” Testing your project for compatibility with freethreaded Python. Testing in single thread doesn't test that. Neither does testing with pytest-xdist, because it uses multiprocessing to parallelize tests. So, Ant and others “made this plugin to help you run your tests in a thread-pool with the GIL disabled, to help you identify if your tests are thread-safe.” “And the first library we tested it on (which was marked as compatible) caused a segmentation fault in CPython! So you should give this a go if you're a package maintainer.” Michael #4: pytest-edit A simple Pytest plugin for opening editor on the failed tests. Type pytest --edit to open the failing test code Be sure to set your favorite editor in the ENV variables Extras Michael: New way to explore Talk Python courses via topics This has been in our mobile apps since their rewrite but finally comes to the web Let's go easy on PyPI, OK? essay Hynek's video: uv IS the Future of Python Packaging djade-pre-commit Polyfill.io, BootCDN, Bootcss, Staticfile attack traced to 1 operator PurgeCSS CLI Python 3.12.7 released Incremental GC and pushing back the 3.13.0 release uv making the rounds LLM fatigue, is it real? Take the Python Developers Survey 2024 Joke: Funny 404 pages We have something at least interesting at pythonbytes.fm
Talk Python To Me - Python conversations for passionate developers
You're about to launch your new app or API, or even just a big refactor of your current project. Will it stand up and deliver when you put it into production or when that big promotion goes live? Or will it wither and collapse? How would you know? Well you would test that of course. We have Anthony Shaw back on the podcast to dive into a wide range of tools and techniques for performance and loading testing of web apps. Episode sponsors Sentry Error Monitoring, Code TALKPYTHON WorkOS Talk Python Courses Links from the show Anthony on Twitter: @anthonypjshaw Anthony's PyCon Au Talk: youtube.com locust load testing tool: locust.io playwright: playwright.dev mimesis: github.com mimesis providers: mimesis.name vscode pets: marketplace.visualstudio.com vscode power-mode: marketplace.visualstudio.com opentelemetry: opentelemetry.io uptime-kuma: github.com Talk Python uptime / status: talkpython.fm/status when your serverless computing bill goes parabolic...: youtube.com Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Mastodon: talkpython Follow Michael on Mastodon: mkennedy
Talk Python To Me - Python conversations for passionate developers
It's an exciting time for the capabilities of Python. We have the Faster CPython initiative going strong, the recent async work, the adoption of typing and on this episode we discuss a new isolation and parallelization capability coming to Python through sub-interpreters. We have Eric Snow who spearheaded the work to get them added to Python 3.12 and is working on the Python API for 3.13 along with Anthony Shaw who has been pushing the boundaries of what you can already do with subinterpreters. Episode sponsors Pybites PDM Sentry Error Monitoring, Code TALKPYTHON Talk Python Courses Links from the show Guests Anthony Shaw: @tonybaloney@fosstodon.org Eric Snow: /@ericsnowcurrently@mastodon.social PEP 684 – A Per-Interpreter GIL: peps.python.org PEP 734 – Multiple Interpreters in the Stdlib: peps.python.org Running Python Parallel Applications with Sub Interpreters: fosstodon.org pytest subinterpreters: fosstodon.org Long-Term Vision for a Parallel Python Programming Model?: fosstodon.org Hypercorn Server: github.com msgspec: jcristharif.com Dill package: pypi.org Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Mastodon: talkpython Follow Michael on Mastodon: mkennedy
Topics covered in this episode: Python 3.13 gets a JIT UniDep - Unified Conda and Pip Dependency Management Don't Start Pull Requests from Your Main Branch instld: The simplest package management Extras Joke Watch on YouTube About the show Sponsored by us! Support our work through: Our courses at Talk Python Training The Complete pytest Course Patreon Supporters Connect with the hosts Michael: @mkennedy@fosstodon.org Brian: @brianokken@fosstodon.org Show: @pythonbytes@fosstodon.org Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Tuesdays at 11am PT. Older video versions available there too. Brian #1: Python 3.13 gets a JIT Anthony Shaw Great article that walks through JIT concepts with a small example as if you were writing a parser in Python instead of C. Covers What is a JIT? What is a copy-and-patch JIT? and Why? How does the Python JIT work? Is it faster? This is a building block to future improvements Michael #2: UniDep - Unified Conda and Pip Dependency Management
This week, Michael, Mark and Gladys talk to Anthony Shaw about some of the best practices and tooling for securing Infrastructure as Code (IaC) solutions. Sarah is away in Singapore, presenting at BlackHat.We also cover security news about DDoS, Cosmos DB, Microsoft Defender for APIs, Load Balancer, Zero Trust and discovering Internet-facing devices.
Talk Python To Me - Python conversations for passionate developers
Deploying and managing your application after you create it can be a big challenge. Cloud platforms such as Azure have literally hundreds of services. Which ones should you choose? How do you link them together? In this episode, Anthony Shaw and Shayne Boyer share a new CLI tool and template they've created for jump starting you use of modern Python apps and deploying them to Azure. We're talking FastAPI, Beanie and MongoDB, async and await, Bicep DevOps, automated CI/CD pipelines and more. Plus we catch up on other Python work happening that Anthony is involved with. If you're interested in deploying or structuring modern Python apps, you'll find some interesting take aways from our conversation. Links from the show Anthony on Twitter: @anthonypjshaw Shayne Boyer: @spboyer Azure azd CLI tools: aka.ms Beanie ODM: github.io Pydantic: helpmanual.io Give me back my monolith article: craigkerstiens.com Python creator Guido van Rossum joins Microsoft: techcrunch.com Making Python Faster with Guido and Mark episode: talkpython.fm Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Sentry Error Monitoring, Code TALKPYTHON NordVPN AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by us! Support our work through: Our courses at Talk Python Training Test & Code Podcast Patreon Supporters Special guest: Nick Muoh Brian #1: picologging From a tweet by Anthony Shaw From README.md “early-alpha” stage project with some incomplete features. (cool to be so up front about that) “Picologging is a high-performance logging library for Python. picologging is 4-10x faster than the logging module in the standard library.” “Picologging is designed to be used as a drop-in replacement for applications which already use logging, and supports the same API as the logging module.” Now you've definitely got my attention. For many common use cases, it's just way faster. Sounds great, why not use it? A few limitations listed: process and thread name not captured. Some logging globals not observed: logging.logThreads, logging.logMultiprocessing, logging.logProcesses Logger will always default to the Sys.stderr and not observe (emittedNoHandlerWarning). Michael #2: CheekyKeys via Prayson Daniel What if you could silently talk to your computer? CheekyKeys uses OpenCV and MediaPipe's Face Mesh to perform real-time detection of facial landmarks from video input. The primary input is to "type" letters, digits, and symbols via Morse code by opening and closing your mouth quickly for . and slightly longer for -. Most of the rest of the keyboard and other helpful actions are included as modifier gestures, such as: shift: close right eye command: close left eye arrow up/down: raise left/right eyebrow … Watch the video where he does a coding interview for a big tech company using no keyboard. Nick #3: Is Google's LaMDA Model Sentient? authored by Richard Luscombe (The Guardian) The Google engineer who thinks the company's AI has come to life Transcript of conversation Brian #4: richbench Also from Anthony “A little Python benchmarking tool.” Give it a list of (first_func, second_func, “label”), and it times them and prints out a comparison. Simple and awesome. def sort_seven(): """Sort a list of seven items""" for _ in range(10_000): sorted([3,2,4,5,1,5,3]) def sort_three(): """Sort a list of three items""" for _ in range(10_000): sorted([3,2,4]) __benchmarks__ = [ (sort_seven, sort_three, "Sorting 3 items instead of 7") ] Michael #5: typeguard A run-time type checker for Python Three principal ways to do type checking are provided, each with its pros and cons: Manually with function calls @typechecked decorator import hook (typeguard.importhook.install_import_hook()) Example: @typechecked def some_function(a: int, b: float, c: str, *args: str) -> bool: ... return retval Nick #6: CustomTkinter A modern and customizable python UI-library based on Tkinter. Extras Michael: OpenSSF Funds Python and Eclipse Foundations - OpenSSF's Alpha-Omega Project has committed $400K to the Python Software Foundation (PSF), in order to create a new role which will provide security expertise for Python, the Python Package Index (PyPI), and the rest of the Python ecosystem, as well as funding a security audit. (via Python Weekly) Nick: Terms of Service Didn't Read - Terms of Service; Didn't Read” (short: ToS;DR) is a young project started in June 2012 to help fix the “biggest lie on the web”: almost no one really reads the terms of service we agree to all the time. Joke: Serverless A DevOps approach to COVID-19
From Frank Sinatra's early pro-Zionist rallying to Steven Spielberg's present-day peacemaking, Hollywood has long enjoyed a “special relationship” with Israel. This book offers a groundbreaking account of this relationship, both on and off the screen. Tony Shaw and Giora Goodman investigate the many ways in which Hollywood's moguls, directors, and actors have supported or challenged Israel for more than seven decades. They explore the complex story of Israel's relationship with American Jewry and illuminate how media and soft power have shaped the Arab-Israeli conflict. In Hollywood and Israel: A History (Columbia University Press, 2022), Shaw and Goodman draw on a vast range of archival sources to demonstrate how show business has played a pivotal role in crafting the U.S.-Israel alliance. They probe the influence of Israeli diplomacy on Hollywood's output and lobbying activities but also highlight the limits of ideological devotion in high-risk entertainment industries. The book details the political involvement with Israel—and Palestine—of household names such as Eddie Cantor, Kirk Douglas, Elizabeth Taylor, Barbra Streisand, Vanessa Redgrave, Arnold Schwarzenegger, Robert De Niro, and Natalie Portman. It also spotlights the role of key behind-the-scenes players like Dore Schary, Arthur Krim, Arnon Milchan, and Haim Saban. Bringing the story up to the moment, Shaw and Goodman contend that the Hollywood-Israel relationship might now be at a turning point. Shedding new light on the political power that images and celebrity can wield, Hollywood and Israel shows the world's entertainment capital to be an important player in international affairs. Nathan Abrams is a professor of film at Bangor University in Wales [https://research.bangor.ac.uk/...(b8c6d91f-14c5-4862-8745-0f5d0e938a28).html]. His most recent work is on film director Stanley Kubrick [https://oxford.universitypress...]. To discuss and propose a book for interview you can reach him at n.abrams@bangor.ac.uk. Twitter: @ndabrams Learn more about your ad choices. Visit megaphone.fm/adchoices Support our show by becoming a premium member! https://newbooksnetwork.supportingcast.fm/jewish-studies
From Frank Sinatra's early pro-Zionist rallying to Steven Spielberg's present-day peacemaking, Hollywood has long enjoyed a “special relationship” with Israel. This book offers a groundbreaking account of this relationship, both on and off the screen. Tony Shaw and Giora Goodman investigate the many ways in which Hollywood's moguls, directors, and actors have supported or challenged Israel for more than seven decades. They explore the complex story of Israel's relationship with American Jewry and illuminate how media and soft power have shaped the Arab-Israeli conflict. In Hollywood and Israel: A History (Columbia University Press, 2022), Shaw and Goodman draw on a vast range of archival sources to demonstrate how show business has played a pivotal role in crafting the U.S.-Israel alliance. They probe the influence of Israeli diplomacy on Hollywood's output and lobbying activities but also highlight the limits of ideological devotion in high-risk entertainment industries. The book details the political involvement with Israel—and Palestine—of household names such as Eddie Cantor, Kirk Douglas, Elizabeth Taylor, Barbra Streisand, Vanessa Redgrave, Arnold Schwarzenegger, Robert De Niro, and Natalie Portman. It also spotlights the role of key behind-the-scenes players like Dore Schary, Arthur Krim, Arnon Milchan, and Haim Saban. Bringing the story up to the moment, Shaw and Goodman contend that the Hollywood-Israel relationship might now be at a turning point. Shedding new light on the political power that images and celebrity can wield, Hollywood and Israel shows the world's entertainment capital to be an important player in international affairs. Nathan Abrams is a professor of film at Bangor University in Wales [https://research.bangor.ac.uk/...(b8c6d91f-14c5-4862-8745-0f5d0e938a28).html]. His most recent work is on film director Stanley Kubrick [https://oxford.universitypress...]. To discuss and propose a book for interview you can reach him at n.abrams@bangor.ac.uk. Twitter: @ndabrams Learn more about your ad choices. Visit megaphone.fm/adchoices Support our show by becoming a premium member! https://newbooksnetwork.supportingcast.fm/new-books-network
From Frank Sinatra's early pro-Zionist rallying to Steven Spielberg's present-day peacemaking, Hollywood has long enjoyed a “special relationship” with Israel. This book offers a groundbreaking account of this relationship, both on and off the screen. Tony Shaw and Giora Goodman investigate the many ways in which Hollywood's moguls, directors, and actors have supported or challenged Israel for more than seven decades. They explore the complex story of Israel's relationship with American Jewry and illuminate how media and soft power have shaped the Arab-Israeli conflict. In Hollywood and Israel: A History (Columbia University Press, 2022), Shaw and Goodman draw on a vast range of archival sources to demonstrate how show business has played a pivotal role in crafting the U.S.-Israel alliance. They probe the influence of Israeli diplomacy on Hollywood's output and lobbying activities but also highlight the limits of ideological devotion in high-risk entertainment industries. The book details the political involvement with Israel—and Palestine—of household names such as Eddie Cantor, Kirk Douglas, Elizabeth Taylor, Barbra Streisand, Vanessa Redgrave, Arnold Schwarzenegger, Robert De Niro, and Natalie Portman. It also spotlights the role of key behind-the-scenes players like Dore Schary, Arthur Krim, Arnon Milchan, and Haim Saban. Bringing the story up to the moment, Shaw and Goodman contend that the Hollywood-Israel relationship might now be at a turning point. Shedding new light on the political power that images and celebrity can wield, Hollywood and Israel shows the world's entertainment capital to be an important player in international affairs. Nathan Abrams is a professor of film at Bangor University in Wales [https://research.bangor.ac.uk/...(b8c6d91f-14c5-4862-8745-0f5d0e938a28).html]. His most recent work is on film director Stanley Kubrick [https://oxford.universitypress...]. To discuss and propose a book for interview you can reach him at n.abrams@bangor.ac.uk. Twitter: @ndabrams Learn more about your ad choices. Visit megaphone.fm/adchoices Support our show by becoming a premium member! https://newbooksnetwork.supportingcast.fm/history
From Frank Sinatra's early pro-Zionist rallying to Steven Spielberg's present-day peacemaking, Hollywood has long enjoyed a “special relationship” with Israel. This book offers a groundbreaking account of this relationship, both on and off the screen. Tony Shaw and Giora Goodman investigate the many ways in which Hollywood's moguls, directors, and actors have supported or challenged Israel for more than seven decades. They explore the complex story of Israel's relationship with American Jewry and illuminate how media and soft power have shaped the Arab-Israeli conflict. In Hollywood and Israel: A History (Columbia University Press, 2022), Shaw and Goodman draw on a vast range of archival sources to demonstrate how show business has played a pivotal role in crafting the U.S.-Israel alliance. They probe the influence of Israeli diplomacy on Hollywood's output and lobbying activities but also highlight the limits of ideological devotion in high-risk entertainment industries. The book details the political involvement with Israel—and Palestine—of household names such as Eddie Cantor, Kirk Douglas, Elizabeth Taylor, Barbra Streisand, Vanessa Redgrave, Arnold Schwarzenegger, Robert De Niro, and Natalie Portman. It also spotlights the role of key behind-the-scenes players like Dore Schary, Arthur Krim, Arnon Milchan, and Haim Saban. Bringing the story up to the moment, Shaw and Goodman contend that the Hollywood-Israel relationship might now be at a turning point. Shedding new light on the political power that images and celebrity can wield, Hollywood and Israel shows the world's entertainment capital to be an important player in international affairs. Nathan Abrams is a professor of film at Bangor University in Wales [https://research.bangor.ac.uk/...(b8c6d91f-14c5-4862-8745-0f5d0e938a28).html]. His most recent work is on film director Stanley Kubrick [https://oxford.universitypress...]. To discuss and propose a book for interview you can reach him at n.abrams@bangor.ac.uk. Twitter: @ndabrams Learn more about your ad choices. Visit megaphone.fm/adchoices Support our show by becoming a premium member! https://newbooksnetwork.supportingcast.fm/middle-eastern-studies
From Frank Sinatra's early pro-Zionist rallying to Steven Spielberg's present-day peacemaking, Hollywood has long enjoyed a “special relationship” with Israel. This book offers a groundbreaking account of this relationship, both on and off the screen. Tony Shaw and Giora Goodman investigate the many ways in which Hollywood's moguls, directors, and actors have supported or challenged Israel for more than seven decades. They explore the complex story of Israel's relationship with American Jewry and illuminate how media and soft power have shaped the Arab-Israeli conflict. In Hollywood and Israel: A History (Columbia University Press, 2022), Shaw and Goodman draw on a vast range of archival sources to demonstrate how show business has played a pivotal role in crafting the U.S.-Israel alliance. They probe the influence of Israeli diplomacy on Hollywood's output and lobbying activities but also highlight the limits of ideological devotion in high-risk entertainment industries. The book details the political involvement with Israel—and Palestine—of household names such as Eddie Cantor, Kirk Douglas, Elizabeth Taylor, Barbra Streisand, Vanessa Redgrave, Arnold Schwarzenegger, Robert De Niro, and Natalie Portman. It also spotlights the role of key behind-the-scenes players like Dore Schary, Arthur Krim, Arnon Milchan, and Haim Saban. Bringing the story up to the moment, Shaw and Goodman contend that the Hollywood-Israel relationship might now be at a turning point. Shedding new light on the political power that images and celebrity can wield, Hollywood and Israel shows the world's entertainment capital to be an important player in international affairs. Nathan Abrams is a professor of film at Bangor University in Wales [https://research.bangor.ac.uk/...(b8c6d91f-14c5-4862-8745-0f5d0e938a28).html]. His most recent work is on film director Stanley Kubrick [https://oxford.universitypress...]. To discuss and propose a book for interview you can reach him at n.abrams@bangor.ac.uk. Twitter: @ndabrams Learn more about your ad choices. Visit megaphone.fm/adchoices Support our show by becoming a premium member! https://newbooksnetwork.supportingcast.fm/israel-studies
From Frank Sinatra's early pro-Zionist rallying to Steven Spielberg's present-day peacemaking, Hollywood has long enjoyed a “special relationship” with Israel. This book offers a groundbreaking account of this relationship, both on and off the screen. Tony Shaw and Giora Goodman investigate the many ways in which Hollywood's moguls, directors, and actors have supported or challenged Israel for more than seven decades. They explore the complex story of Israel's relationship with American Jewry and illuminate how media and soft power have shaped the Arab-Israeli conflict. In Hollywood and Israel: A History (Columbia University Press, 2022), Shaw and Goodman draw on a vast range of archival sources to demonstrate how show business has played a pivotal role in crafting the U.S.-Israel alliance. They probe the influence of Israeli diplomacy on Hollywood's output and lobbying activities but also highlight the limits of ideological devotion in high-risk entertainment industries. The book details the political involvement with Israel—and Palestine—of household names such as Eddie Cantor, Kirk Douglas, Elizabeth Taylor, Barbra Streisand, Vanessa Redgrave, Arnold Schwarzenegger, Robert De Niro, and Natalie Portman. It also spotlights the role of key behind-the-scenes players like Dore Schary, Arthur Krim, Arnon Milchan, and Haim Saban. Bringing the story up to the moment, Shaw and Goodman contend that the Hollywood-Israel relationship might now be at a turning point. Shedding new light on the political power that images and celebrity can wield, Hollywood and Israel shows the world's entertainment capital to be an important player in international affairs. Nathan Abrams is a professor of film at Bangor University in Wales [https://research.bangor.ac.uk/...(b8c6d91f-14c5-4862-8745-0f5d0e938a28).html]. His most recent work is on film director Stanley Kubrick [https://oxford.universitypress...]. To discuss and propose a book for interview you can reach him at n.abrams@bangor.ac.uk. Twitter: @ndabrams Learn more about your ad choices. Visit megaphone.fm/adchoices Support our show by becoming a premium member! https://newbooksnetwork.supportingcast.fm/american-studies
From Frank Sinatra's early pro-Zionist rallying to Steven Spielberg's present-day peacemaking, Hollywood has long enjoyed a “special relationship” with Israel. This book offers a groundbreaking account of this relationship, both on and off the screen. Tony Shaw and Giora Goodman investigate the many ways in which Hollywood's moguls, directors, and actors have supported or challenged Israel for more than seven decades. They explore the complex story of Israel's relationship with American Jewry and illuminate how media and soft power have shaped the Arab-Israeli conflict. In Hollywood and Israel: A History (Columbia University Press, 2022), Shaw and Goodman draw on a vast range of archival sources to demonstrate how show business has played a pivotal role in crafting the U.S.-Israel alliance. They probe the influence of Israeli diplomacy on Hollywood's output and lobbying activities but also highlight the limits of ideological devotion in high-risk entertainment industries. The book details the political involvement with Israel—and Palestine—of household names such as Eddie Cantor, Kirk Douglas, Elizabeth Taylor, Barbra Streisand, Vanessa Redgrave, Arnold Schwarzenegger, Robert De Niro, and Natalie Portman. It also spotlights the role of key behind-the-scenes players like Dore Schary, Arthur Krim, Arnon Milchan, and Haim Saban. Bringing the story up to the moment, Shaw and Goodman contend that the Hollywood-Israel relationship might now be at a turning point. Shedding new light on the political power that images and celebrity can wield, Hollywood and Israel shows the world's entertainment capital to be an important player in international affairs. Nathan Abrams is a professor of film at Bangor University in Wales [https://research.bangor.ac.uk/...(b8c6d91f-14c5-4862-8745-0f5d0e938a28).html]. His most recent work is on film director Stanley Kubrick [https://oxford.universitypress...]. To discuss and propose a book for interview you can reach him at n.abrams@bangor.ac.uk. Twitter: @ndabrams Learn more about your ad choices. Visit megaphone.fm/adchoices Support our show by becoming a premium member! https://newbooksnetwork.supportingcast.fm/american-west
www.trypyjion.com main websitehttps://live.trypyjion.com/ in-browser compilerhttps://github.com/tonybaloney/Pyjion source repohttps://www.youtube.com/watch?v=I4nkgJdVZFA PyCon talk “Why is Python slow”
Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Special guest: Emily Morehouse-Valcarcel Michael #1: Async and await with subprocesses by Fredrik Averpil People know I do all sorts of stuff with async Lots of cool async things are not necessarily built into Python, but our instead third-party packages E.g. files via aiofiles But asyncio has asyncio.create_subprocess_exec Fredrik's article has some nice examples I started using this for mp3 uploads and behind the scenes processing for us Brian #2: Typesplainer Arian Mollik Wasi, @wasi_master Suggested by Will McGugan Now released a vscode extension for that! Available on vscode as typesplainer Emily #3: Ibis Project via Marlene Mhangami “Productivity-centric Python data analysis framework for SQL engines and Hadoop” focused on: Type safety Expressiveness Composability Familiarity Marlene wrote an excellent blog post as an introduction Works with tons of different backends, either directly or via compilation Depending on the backend, it actually uses SQLAlchemy under the hood There's a ton of options for interacting with a SQL database from Python, but Ibis has some interesting features geared towards performance and analyzing large sets of data. It's a great tool for simple projects, but an excellent tool for anything data science related since it plays so nicely with things like pandas Michael #4: ASV via Will McGugan AirSpeed Velocity (asv) is a tool for benchmarking Python packages over their lifetime. Runtime, memory consumption and even custom-computed values may be tracked. See quickstart Example of astropy here. Finding a commit that produces a large regression Brian #5: perflint Anthony Shaw pylint extension for performance anti patterns curious why a pylint extension and not a flake8 plugin. I think the normal advice of “beware premature optimization” is good advice. But also, having a linter show you some code habits you may have that just slow things down is a nice learning tool. Many of these items are also not going to be the big show stopper performance problems, but they add unnecessary performance hits. To use this, you also have to use pylint, and that can be a bit painful to start up with, as it's pretty picky. Tried it on a tutorial project today, and it complained about any variable, or parameter under 3 characters. Seems a bit picky to me for tutorials, but probably good advice for production code. These are all configurable though, so you can dial back the strictness if necessary. perflint checks: W8101 : Unnessecary list() on already iterable type W8102: Incorrect iterator method for dictionary W8201: Loop invariant statement (loop-invariant-statement) ←- very cool W8202: Global name usage in a loop (loop-invariant-global-usage) R8203 : Try..except blocks have a significant overhead. Avoid using them inside a loop (loop-try-except-usage). W8204 : Looped slicing of bytes objects is inefficient. Use a memoryview() instead (memoryview-over-bytes) W8205 : Importing the "%s" name directly is more efficient in this loop. (dotted-import-in-loop) Emily #6: PEP 594 Acceptance “Removing dead batteries from the standard library” Written by Christian Heimes and Brett Cannon back in 2019, though the conversation goes back further than that It's a very thin line for modules that might still be useful to someone versus the development effort needed to maintain them. Recently accepted, targeting Python 3.11 (final release planned for October 2022, development begins in May 2021. See the full release schedule) Deprecations will begin in 3.11 and modules won't be fully removed until 3.13 (~October 2024) See the full list of deprecated modules Bonus: new PEP site and theme! Extras Brian: Michael: Emily: Riff off of one of Brian's topics from last week: Automate your interactive rebases with fixups and auto-squashing Cool award that The PSF just received PSF Spring Fundraiser Cuttlesoft is hiring! Jokes: *Changing * (via Ruslan) Please hire me
How can you can speed up Python? Have you thought of using a JIT (Just-In-Time Compiler)? This week on the show, we have Real Python author and previous guest Anthony Shaw to talk about his project Pyjion, a drop-in JIT compiler for CPython 3.10.
Hello and welcome to CHAOSScast Community podcast, where we share use cases and experiences with measuring open source community health. Elevating conversations about metrics, analytics, and software from the Community Health Analytics Open Source Software, or short CHAOSS Project, to wherever you like to listen. Today, we have three amazing guests with us, Amanda Casari, Katie McLaughlin, and John Meluso. Amanda is a Developer Relations Engineer and researcher at Google at the Open Source Programs Office, Katie is a Developer Relations Engineer at Google, and John is the OCEAN Postdoctoral Fellow at the University of Vermont. They are with us to talk about Project OCEAN (Open-Source Complex Ecosystems And Networks), how it came to be, where it is now, and what they hope to accomplish going forward. We also learn more about what they see as an open source ecosystem, and they go in depth about contributions and taxonomy. Download this episode now to find out much more, and don't forget to subscribe for free to this podcast on your favorite podcast app and share this podcast with your friends and colleagues! [00:03:44] John, Amanda, and Katie tell us their backgrounds and how they got involved in open source. [00:07:23] We learn more about OCEAN, how it came to be, and where it's at now. [00:11:25] Amanda and John explain a bit more about ecosystems. [00:15:52] Georg wonders what they have realized early on or over time that they want to make sure everyone who looks at open source takes away from their work. [00:19:59] Amanda brings up a question to the panelists concerning the idea of atomic information around software projects and balancing how much do they keep with a repo versus how do you allow for information to be distributed in many places that many people work, but it doesn't get lost and you don't lose somebody's attribution for the work they do. [00:28:58] Georg brings up the Types of Contributions metrics link CHAOSS uses that helps show how people can contribute to open source, and Katie shares her thoughts on it. [00:32:13] Sophie talks about “Which contributions count? Analysis of attribution in open source” report and what this research explores. John explains how they balance things by varying the kinds of methodologies they use. [00:38:49] Find out where you can follow Amanda, Katie, and John online. Value Adds (Picks) of the week: [00:39:45] Georg's pick is LifeTime wellness and fitness center. [00:40:31] Matt's pick is places to visit in Colorado: Rocky Mtn. National Park, Great Sand Dunes, and Gunnison National Park. [00:41:08] Sophia's pick is emergent property. [00:41:57] Amanda's pick is trading Vermont Golden Dome books with her oldest child. [00:43:10] Katie's pick is the book, CPython Internals by Anthony Shaw. [00:44:03] John's pick is the book, Data Feminism by Catherine D'Ignazio and Lauren F. Klein. Request from our Guests: Open Source Folks: Take (and share!) this anonymous survey about receiving credit for tasks in open source! Conducted by researchers at the University of Vermont in partnership with Google Open Source. [https://qualtrics.uvm.edu/jfe/form/SV_1zUs19oVcZJ0SPA](https://qualtrics.uvm.edu/jfe/form/SV_1zUs19oVcZJ0SPA) Panelists: Georg Link Sophia Vargas Matt Germonprez Guests: Amanda Casari Katie McLaughlin John Meluso Sponsor: SustainOSS (https://sustainoss.org/) Links: CHAOSS (https://chaoss.community/) CHAOSS Project Twitter (https://twitter.com/chaossproj?lang=en) CHAOSScast Podcast (https://podcast.chaoss.community/) podcast@chaoss.community (mailto:podcast@chaoss.community) Project OCEAN (https://vermontcomplexsystems.org/partner/OCEAN/) Amanda Casari Twitter (https://twitter.com/amcasari?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor) Open Source Stories-Amanda Casari Website (https://www.opensourcestories.org/) Amanda Casari Linkedin (https://www.linkedin.com/in/amcasari/) Katie McLaughlin Twitter (https://twitter.com/glasnt) Katie McLaughlin Website (https://glasnt.com/) John Meluso Twitter (https://twitter.com/johnmeluso) John Meluso Linkedin (https://www.linkedin.com/in/jmeluso/) John Meluso, PhD Website (https://www.johnmeluso.com/) John Meluso Email (mailto:john.meluso@uvm.edu) ACROSS Taxonomy-GitHub (https://github.com/google/across) CHAOSS Types of Contributions metrics (https://chaoss.community/metric-types-of-contributions/) Which contributions count? Analysis of attribution in open source-Jean-Gabriel Young, Amanda Casari, Katie McLaughlin, Milo Z. Trujillo, Laurent Hébert-Dufresne, James P. Bagrow (https://arxiv.org/abs/2103.11007) Open source ecosystems need equitable credit across contributions-Amanda Casari, Katie McLaughlin, Milo Z. Trujillo, Jean-Gabriel young, James P. Bagrow, & Laurent Hébert-Dufresne (https://www.nature.com/articles/s43588-020-00011-w) Nadia Eghbal Website (https://nadiaeghbal.com/) Roads and Bridges: The Unseen Labor Behind Our Digital Infrastructure by Nadia Eghbal (https://www.fordfoundation.org/work/learning/research-reports/roads-and-bridges-the-unseen-labor-behind-our-digital-infrastructure/) Working in Public: The Making and Maintenance of Open Source Software by Nadia Eghbal (https://www.amazon.com/Working-Public-Making-Maintenance-Software/dp/0578675862) A Place to Hang Your Hat- Leslie Hawthorn's Hat Rack blog post (https://hawthornlandings.org/2015/02/13/a-place-to-hang-your-hat/) Octohatrack-GitHub (https://github.com/LABHR/octohatrack) A tool for tracking non-code GitHub contributions-Katie McLaughlin (https://opensource.com/life/15/10/octohat-github-non-code-contribution-tracker) Recognize All Contributors (https://allcontributors.org/) CHAOSScast Podcast- Episode 39: Leaderboards and Metrics at Drupal.org with Matthew Tift and Tim Lehnen (https://podcast.chaoss.community/39) LifeTime (https://www.lifetime.life/) Rocky Mountain National Park (https://www.nps.gov/romo/index.htm) Great Sand Dunes (https://www.nps.gov/grsa/index.htm) Black Canyon Of The Gunnison (https://www.nps.gov/blca/index.htm) What Are Emergent Properties? (https://sciencing.com/emergent-properties-8232868.html) Vermont Golden Dome Books (https://libraries.vermont.gov/services/children_and_teens/book_awards/vtgdba) CPython Internals by Andrew Shaw (https://realpython.com/products/cpython-internals-book/) Data Feminism by Catherine D'Ignazio (https://www.amazon.com/Feminism-Strong-Ideas-Catherine-DIgnazio/dp/0262044005/) Special Guests: Amanda Casari, John Meluso, and Katie McLaughlin.
Watch the live stream: Watch on YouTube About the show Sponsored by us: Check out the courses over at Talk Python And Brian's book too! Special guest: Matt Kramer (@__matt_kramer__) Michael #1: Survey results Question 1: Question 2: In terms of too long, the “extras” section has started at these times in the last 4 episodes: 39m, 32m, 35m, and 33m ~= 34m on average Brian #2: Modern attrs API attrs overview now focus on using @define History of attrs article: import attrs, by Hynek predecessor was called characteristic. A discussion between Glyph and Hynek in 2015 about where to take the idea. attrs popularity takes off in 2016 after a post by Glyph: The One Python Library Everyone Needs In 2017 people started wanting something like attrs in std library. Thus PEP 557 and dataclasses. Hynek, Eric Smith, and Guido discuss it at PyCon US 2017. dataclasses, with a subset of attrs functionality, was introduced in Python 3.7. Types take off. attrs starts supporting type hints as well, even before Python 3.7 Post 3.7, some people start wondering if they still need attrs, since they have dataclasses. @define, field() and other API improvements came with attrs 20.1.0 in 2020. attrs 21.3.0 released in December, with what Hynek calls “Modern attrs”. OG attrs: import attr @attr.s class Point: x = attr.ib() y = attr.ib() modern attrs: from attr import define @define class Point: x: int y: int Many reasons to use attrs listed in Why not…, which is an excellent read. why not dataclasses? less powerful than attrs, intentionally attrs has validators, converters, equality customization, … attrs doesn't force type annotation if you don't like them slots on by default, dataclasses only support slots in Python 3.10 and are off by default attrs can and will move faster See also comparisons with pydantic, named tuples, tuples, dicts, hand-written classes Matt #3: Crafting Interpreters Wanting to learn more about how Python works “under the hood”, I first read Anthony Shaw's CPython internals book A fantastic, detailed overview of how CPython is implemented Since I don't have a formal CS background, I found myself wanting to learn a bit more about the fundamentals Parsing, Tokenization, Bytecode, data structures, etc. Crafting Interpreters is an incredible book by Bob Nystrom (on Dart team at Google) Although not Python, you walk through the implementation of a dynamic, interpreted language from scratch Implement same language (called lox) in two interpreters First a direct evaluation of Abstract Syntax Tree, written in Java Second is a bytecode interpreter, written from the ground up in C, including a compiler Every line of code is in the book, it is incredibly well-written and beautifully rendered I highly recommend to anyone wanting to learn more about language design & implementation Michael #4: Yamele - A schema and validator for YAML via Andrew Simon A basic schema: name: str() age: int(max=200) height: num() awesome: bool() And some YAML that validates: name: Bill age: 26 height: 6.2 awesome: True Take a look at the Examples section for more complex schema ideas. ⚠️ Ensure that your schema definitions come from internal or trusted sources. Yamale does not protect against intentionally malicious schemas. Brian #5: pympler Inspired by something Bob Belderbos wrote about sizes of objects, I think. “Pympler is a development tool to measure, monitor and analyze the memory behavior of Python objects in a running Python application. By pympling a Python application, detailed insight in the size and the lifetime of Python objects can be obtained. Undesirable or unexpected runtime behavior like memory bloat and other “pymples” can easily be identified.” 3 separate modules for profiling asizeof module provides basic size information for one or several Python objects muppy is used for on-line monitoring of a Python application Class Tracker provides off-line analysis of the lifetime of selected Python objects. asizeof is what I looked at recently In contrast to sys.getsizeof, asizeof sizes objects recursively. You can use one of the asizeof functions to get the size of these objects and all associated referents: >>> from pympler import asizeof >>> obj = [1, 2, (3, 4), 'text'] >>> asizeof.asizeof(obj) 176 >>> print(asizeof.asized(obj, detail=1).format()) [1, 2, (3, 4), 'text'] size=176 flat=48 (3, 4) size=64 flat=32 'text' size=32 flat=32 1 size=16 flat=16 2 size=16 flat=16 “Function flatsize returns the flat size of a Python object in bytes defined as the basic size plus the item size times the length of the given object.” Matt #6: hvPlot Interactive hvPlot is a high-level plotting API that is part of the PyData ecosystem, built on HoloViews My colleague Phillip Rudiger recently gave a talk at PyData Global on a new .interactive feature Here's an announcement in the HoloViz forum Allows integration of widgets directly into pandas analysis pipeline (method-chain), so you can add interactivity to your notebook for exploratory data analysis, or serve it as a Panel app Gist & video by Marc Skov Madsen Extras Michael: Typora app, recommended! Congrats Will Got a chance to solve a race condition with Tenacity New project management at GitHub Matt: Check out new Anaconda Nucleus Community forums! We're hiring, and remote-first. Check out anaconda.com/careers Pre-compiled packages now available for Pyston We have an upcoming webinar from Martin Durant: When Your Big Problem is I/O Bound Joke:
Jennika Anthony-Shaw is a Barrister who held the position of Project Manager and Commercial Group Proceedings Coordinator for the Supreme Court of Victoria. Jennika has performance degrees from McGill University and the Manhattan School of Music and built a successful freelance career as a global trotting Cellist before embarking upon the path that would lead her to the lawQUOTES“I started out in New York where everyone is really good. There's 3 or 4 top music schools in the city and you do have to compete for work or create your own work.”“I didn't want to let myself down. I felt there was a lot of expectation to keep succeeding, keep playing music and to somehow manage to progress my career beyond where it was.”As musicians we like to think we can work anywhere, it is odd to think sometimes you're prevented from doing that.”LINKSFind Jennika on LinkedINPODCAST TEAMProduction Penny ManwaringAudio Engineering from Frazer RuddickTheme Music Composed by Danna YunTheme Music Composed by Natasha PearsonTheme Music Performed by Alison McIntosh-Deszcz (soprano), Natasha Lin (piano), and Susan Eldridge (horn). Theme Music Recorded Lady Marigold Southey Performance Studio, 3MBS Fine Music in Melbourne in October 2016. With thanks to recording engineer Cheryl Scott.FIRST BROADCAST27 December 2016
Watch the live stream: Watch on YouTube About the show Sponsored by Shortcut - Get started at shortcut.com/pythonbytes Special guest: Renee Teate Michael #1: pypi-changes via Brian Skinn, created by Bernát Gábor Visually show you which dependencies in an environment are out of date. See the age of everything you depend upon. Also, shoutout again to pipdeptree Brian #2: Late-bound argument defaults for Python Default values for arguments to functions are evaluated at function definition time. If a value is a short expression that uses a variable, that variable is in the scope of the function definition. The expression cannot use other arguments. Example of what you cannot do: def foo(a, b = None, c = len(a)): ... There's a proposal by Chris Angelico to add a =: operator for late default evaluation. syntax still up in the air. => and ?= also discussed However, it's non-trivial to add syntax to an established language, and this article notes: At first blush, Angelico's idea to fix this "wart" in Python seems fairly straightforward, but the discussion has shown that there are multiple facets to consider. It is not quite as simple as "let's add a way to evaluate default arguments when the function is called"—likely how it was seen at the outset. That is often the case when looking at new features for an established language like Python; there is a huge body of code that needs to stay working, but there are also, sometimes conflicting, aspirations for features that could be added. It is a tricky balancing act. Renee #3: pandas.read_sql Since I wrote my book SQL for Data Scientists, I've gotten several questions about how I use SQL in my python scripts. It's really simple: You can save your SQL as a text file and then import the dataset into a pandas dataframe to do the rest of my data cleaning, feature engineering, etc. Pandas has a built-in way to use SQL as a data source. You set up a connection to your database using another package like SQL Alchemy, then send the SQL string and the connection to the pandas.read_sql function. It returns a dataframe with the results of your query. Michael #4: pyjion by Anthony Shaw Pyjion is a JIT for Python based upon CoreCLR Check out live.trypyjion.com *to see it in action.* Requires Python 3.10, .NET Core 6 Enable with just a couple of lines: >>> import pyjion >>> pyjion.enable() Brian #5: Tips for debugging with print() Adam Johnson 7 tips altogether, but I'll highlight a few I loved reading about Debug variables with f-strings and = print(f``"``{myvar=}``") Saves typing over print(f``"``myvar={myvar}") with the same result Make output “pop” with emoji (Brilliant!) print("
Talk Python To Me - Python conversations for passionate developers
Is Python slow? We touched on that question with Guido and Mark last episode. This time we welcome back friend of the show, Anthony Shaw. Here's there to share the massive amount of work he's been doing to answer that question and speed things up where they answer is yes. He's just released version 1.0 of the Pyjion project. Pyjion is a drop-in JIT compiler for Python 3.10. Pyjion uses the power of the .NET 6 cross-platform JIT compiler to optimize Python code on the fly, with NO changes to your source code required. It runs on Linux, macOS, and Windows, x64 and ARM64. Links from the show Anthony on Twitter: @anthonypjshaw Pyjion: github.com Restarting Pyjion Presentation: youtube.com Hathi: SQL host scanner and dictionary attack tool: github.com Try Pyjion online: trypyjion.com Pyjion optimizations: readthedocs.io Pyjion docs: readthedocs.io .NET: dotnet.microsoft.com PEP 523: python.org Pydantic validation decorator: helpmanual.io Tortoise ORM: github.com pypy: pypy.org Numba: numba.pydata.org NGen AOT Compiler: microsoft.com Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm ---------- Stay in touch with us ---------- Subscribe on YouTube (for live streams): youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Shortcut Linode AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by Shortcut - Get started at shortcut.com/pythonbytes Special guest: The Anthony Shaw Michael #0: It's episode 2^8 (nearly 5 years of podcasting) Brian #1: Where does all the effort go?: Looking at Python core developer activity Łukasz Langa A look into CPython repository history and PR data Also, nice example of datasette in action and lots of SQL queries. The data, as well as the process, is open for anyone to look at. Cool that the process was listed in the article, including helper scripts used. Timeframe for data is since Feb 10, 2017, when source moved to GitHub, through Oct 9, 2021. However, some queries in the article are tighter than that. Queries Files involved in PRs since 1/1/20 top is ceval.c with 259 merged PRs Contributors by number of merged PRs lots of familiar names in the top 50, along with some bots it'd be fun to talk with someone about the bots used to help the Python project nice note: “Clearly, it pays to be a bot … or a release manager since this naturally causes you to make a lot of commits. But Victor Stinner and Serhiy Storchaka are neither of these things and still generate amazing amounts of activity. Kudos! In any case, this is no competition but it was still interesting to see who makes all these recent changes.” Who contributed where? Neat. There's a self reported Experts Index in the very nice Python Developer's Guide. But some libraries don't have anyone listed. The data does though. Łukasz generated a top-5 list for each file. Contributing to some file and have a question. These folks may be able to help. Averages for PR activity core developer authoring and merging their own PR takes on average ~7 days (std dev ±41.96 days); core developer authoring a PR which was merged by somebody else takes on average 20.12 days (std dev ±77.36 days); community member-authored PRs get merged on average after 19.51 days (std dev ±81.74 days). Interesting note on those std deviations: “Well, if we were a company selling code review services, this standard deviation value would be an alarmingly large result. But in our situation which is almost entirely volunteer-driven, the goal of my analysis is to just observe and record data. The large standard deviation reflects the large amount of variation but isn't necessarily something to worry about. We could do better with more funding but fundamentally our biggest priority is keeping CPython stable. Certain care with integrating changes is required. Erring on the side of caution seems like a wise thing to do.” More questions to be asked, especially from the issue tracker Which libraries require most maintenance? Michael #2: Why you shouldn't invoke setup.py directly By Paul Ganssle (from Talk Python #271: Unlock the mysteries of time, Python's datetime that is!) In response to conversation in Talk Python's cibuildwheel episode? For a long time, setuptools and distutils were the only game in town when it came to creating Python packages You write a setup.py file that invokes the setup() method, you get a Makefile-like interface exposed by invoking python setup.py [HTML_REMOVED] The last few years all direct invocations of setup.py are effectively deprecated in favor of invocations via purpose-built and/or standards-based CLI tools like pip, build and tox. In Python 2.0, the distutils module was introduced as a standard way to convert Python source code into *nix distro packages One major problem with this approach, though, is that every Python package must use distutils and only distutils — there was no standard way for a package author to make it clear that you need other packages in order to build or test your package. => Setuptools Works, but sometimes you need requirements before the install (see cython example) A build backend is something like setuptools or flit, which is a library that knows how to take a source tree and turn it into a distributable artifact — a source distribution or a wheel. A build frontend is something like pip or build, which is a program (usually a CLI tool) that orchestrates the build environment and invokes the build backend In this taxonomy, setuptools has historically been both a backend and a frontend - that said, setuptools is a terrible frontend. It does not implement PEP 517 or PEP 518's requirements for build frontends Why am I not seeing deprecation warnings? Use build package. Also can be replaced by tox, nox or even a Makefile Probably should just check out the summary table. Anthony #3: OpenTelemetry is going stable soon Cloud Native Computing Foundation project for cross-language event tracing, performance tracing, logging and sampling for distributed applications. Engineers from Microsoft, Amazon, Splunk, Google, Elastic, New Relic and others working on standards and specification. Formed through a merger of the OpenTracing and OpenCensus projects. Python SDK supports instrumentation of lots of frameworks, like Flask, Django, FastAPI (ASGI), and ORMs like SQLalchemy, or templating engines. All data can then be exported onto various platforms : NewRelic, Prometheus, Jaeger, DataDog, Azure Monitor, Google Cloud Monitoring. If you want to get started and play around, checkout the rich console exporter I submitted recently. Brian #4: Understanding all of Python, through its builtins Tushar Sadhwani I really enjoyed the discussion before he actually got to the builtins. LEGB rule defines the order of scopes in which variables are looked up in Python. Local, Enclosing (nonlocal), Global, Builtin Understanding LEGB is a good thing to do for Python beginners or advanced beginners. Takes a lot of the mystery away. Also that all the builtins are in one The rest is a quick scan through the entire list. It's not detailed everywhere, but pulls over scenic viewpoints at regular intervals to discuss interesting parts of builtins. Grouped reasonably. Not alphabetical Constants: There's exactly 5 constants: True, False, None, Ellipsis, and NotImplemented. globals and locals: Where everything is stored bytearray and memoryview: Better byte interfaces bin, hex, oct, ord, chr and ascii: Basic conversions … Well, it's a really long article, so I suggest jumping around and reading a section or two, or three. Luckily there's a nice TOC at the top. Michael #5: FastAPI, Dask, and more Python goodies win best open source titles Things that stood out to me FastAPI Dask Windows Terminal minikube - Kubernetes cluster on your PC OBS Studio Anthony #6: Notes From the Meeting On Python GIL Removal Between Python Core and Sam Gross Following on from last week's share on the “nogil” branch by Sam Gross, the Core Dev sprint included an interview. Targeted to 3.9 (alpha 3!), needs to at least be updated to 3.9.7. Nogil: Replaces pymalloc with mimalloc for thread safety Ties objects to the thread that created them witha. non-atomic local reference count within the owner thread Allows for (slower) reference counting from other threads. Immortalized some objects so that references never get inc/dec'ed like True, False, None, etc. Deferred reference counting Adjusts the GC to wait for all threads to pause at a safe point, doesn't wait for I/O blocked threads and constructs a list of objects to deallocate using mimalloc Relocates the MRO to a thread local (instead of process-local) to avoid contention on ref counting Modifies the builtin collections to be thread-safe (lists, dictionaries, etc,) since they could be shared across threads. IMHO, biggest thing to happen to Python in 5 years. Encouragingly, Sam was invited to be a Core Dev and Lukasz will mentor him! Extras Michael Python Developers Survey 2021 is open More PyPI CLI updates bump2version via Bahram Aghaei (youtube comment) Was there a bee stuck in Brian's mic last time? Brian PyCon US 2022 CFP is open until Dec 20 Python Testing with pytest, 2nd edition, Beta 7.0 All chapters now there. (Final chapter was “Advanced Parametrization”) It's in technical review phase now. If reading, please skip ahead to the chapter you really care about and submit errata if you find anything confusing. Joke:
Watch the live stream: Watch on YouTube About the show Sponsored by us: Check out the courses over at Talk Python And Brian's book too! Special guest: Muhammad Raza Brian #1: yaml, GH Actions, and Python 3.10 Anthony Shaw (and others) Old: python: [3.7, 3.8, 3.9, 3.10-dev] New: python: ["3.7", "3.8", "3.9", "3.10"] Reasons: Github Actions use yaml. yaml treats 3.10-dev as a string, since it's got non-numbers in it. yaml treats 3.10 as a number, and is the same as 3.1 hence, we have to use quotes for “3.10” using them on “3.7”, etc is not necessary, but is a nice consistency Michael #2: Beating C and Java, Python Becomes the #1 Most Popular Programming Language, Says TIOBE via Brain Skin "For the first time in more than 20 years we have a new leader of the pack..." the TIOBE Index announced this month. "The long-standing hegemony of Java and C is over.” For Tiobe, its enterprise focus, has seen Java and C dominate in recent years, but Python has been snapping at the heels of Java, and has now overtaken it... "Its ease of learning, its huge amount of libraries, and its widespread use in all kinds of domains, has made it the most popular programming language of today. Congratulations Guido van Rossum!" Muhammad #3: Newspaper3k: Article scraping & curation News, full-text, and article metadata extraction This allows you extract useful information from news articles, similar to Pocket or InstaPaper. Brian #4: PEP 660, pip 21.3, flit 3.4 -> easy editable installs pip install -e /local/dir is a great way to have a project installed while you are developing it. It used to not work with pyproject.toml based projects. Flit worked around this with flit install --``pth-file (or --symlink) PEP660 - Editable installs for pyproject.toml based builds (wheel based) Plus tons of work by Stéphane Bidoul and others, see Test & Code, episode 163 pip 21.3 (Oct 11), flit 3.4 (Oct 10) now support PEP660 And now with pip 21.3 and flit 3.4, pip install -e works for flit projects If you are using optional dependencies, for example: [project.optional-dependencies] test = [ "pytest", "tox", ] Then you need to use a quotes: pip install -e ".[test]" Michael #5: Mito - a JupterLab Extension - generates Python code while you work on your analysis via Tomas Rollo Mito is a spreadsheet that helps you complete your Python analyses 10x faster. You edit the Mitosheet, and it generates Python code for you. Best way to experience it is to watch the video Muhammad #6: troposphere Python library to create AWS CloudFormation descriptions The troposphere library allows easier creation of CloudFormation templates by writing Python code to describe AWS resources. Extras Muhammad How to learn Unix Tools Brian PyCon 2022 site is live, https://us.pycon.org/2022/ Joke: Alphabet cancels Loon
This week Gareth is joined by Anthony Shaw.Anthony is founder of Raw Strength Gym, based in Warrington, UK, a podcast host and competes in strongman competitions! -Anthony tell his story of entrepreneurship, including some really important message about overcoming adversity and work ethic! Gareth and Anthony also take a dive into mindset, vulnerability and self care!-Connect with Anthony here:Podcast: https://omny.fm/shows/the-leader-lifestyle-podcastWebsite: http://theleaderlifestyle.com/Instagram: https://www.instagram.com/theleaderlifestyle/?hl=en-Be the best possible version of yourself.-#podcaster #podcast #starttalking #surroundyourself #bethepebble #mentalhealth #mentalhealthawareness #conversations #community #foreveryone #men #women #diversity #inclusion #parenting #success #happiness #fulfillment-Support The Show* Become a Patron and support the amazing guests and conversations we bring you every week! http://www.patreon.com/starttalking* Buy Us A Coffee: A one time donation helps us keep the mics on! https://www.buymeacoffee.com/starttalking-Want To Start A Podcast?Using the link below let's Buzzsprout know we sent you, gets you a $20 Amazon gift card if you sign up for a paid plan, and helps support our showhttps://www.buzzsprout.com/?referrer_id=303359-Join the conversation at https://weas.ca/ or https://www.flowcode.com/page/we_as_starttalking-Follow us on Instagram, Facebook, Twitter & YouTube:https://www.instagram.com/we_as_starttalking/https://www.facebook.com/WeAsStartTalkinghttps://twitter.com/we_as_https://www.youtube.com/channel/UCwtKEIMBrxzrH4lUvHFrFHASupport the show (https://www.patreon.com/starttalking)
This week Gareth is joined by Anthony Shaw.Anthony is founder of Raw Strength Gym, based in Warrington, UK, a podcast host and competes in strongman competitions! -Anthony tell his story of entrepreneurship, including some really important message about overcoming adversity and work ethic! Gareth and Anthony also take a dive into mindset, vulnerability and self care!-Connect with Anthony here:Podcast: https://omny.fm/shows/the-leader-lifestyle-podcastWebsite: http://theleaderlifestyle.com/Instagram: https://www.instagram.com/theleaderlifestyle/?hl=en-Be the best possible version of yourself.-#podcaster #podcast #starttalking #surroundyourself #bethepebble #mentalhealth #mentalhealthawareness #conversations #community #foreveryone #men #women #diversity #inclusion #parenting #success #happiness #fulfillment-Support The Show* Become a Patron and support the amazing guests and conversations we bring you every week! http://www.patreon.com/starttalking* Buy Us A Coffee: A one time donation helps us keep the mics on! https://www.buymeacoffee.com/starttalking-Want To Start A Podcast?Using the link below let's Buzzsprout know we sent you, gets you a $20 Amazon gift card if you sign up for a paid plan, and helps support our showhttps://www.buzzsprout.com/?referrer_id=303359-Join the conversation at https://weas.ca/ or https://www.flowcode.com/page/we_as_starttalking-Follow us on Instagram, Facebook, Twitter & YouTube:https://www.instagram.com/we_as_starttalking/https://www.facebook.com/WeAsStartTalkinghttps://twitter.com/we_as_https://www.youtube.com/channel/UCwtKEIMBrxzrH4lUvHFrFHASupport the show (https://www.patreon.com/starttalking)
This week we have a very special guest on the podcast, our mate, Anthony Shaw.There are so many things we discuss in this episode but we essentially discuss his career path, his switch from a managerial to a software dev / advocate role at Microsoft and, his process for writing his book, CPython Internals. Most importantly though, we dive into the mindset involved with every one of these endeavours.Thanks so much to Anthony for joining us and having such a deep and raw chat about his experiences. We couldn't be more grateful!Some of the valuable takeaways:Getting a tech job? Make sure you interview them too!You can actually wear many hats (more than you might think) in a big company.How to keep your tech skills up if your main role is not that of a developer?Finding the balance between individual contributor and manager, is there even one?Sometimes you have to take chances to find out what you really like doing the most.How getting out there / sharing knowledge is one of the best things you can do in your career.Dealing with impostor syndrome, especially if you're up to a massive technical endeavour with little prior reference materials.How do you break down such a big endeavour, where to even start? How to approach it?We talk about how to effectively learn a programming language / technical topics (no more tutorial paralysis / embrace reinforcement learning).Specific methodologies Anthony used to really learn the CPython internals.How to overcome decision fatigue.And more...As you can see this episode is jam-packed with things that are dear to us developers.You can reach out to Anthony here:https://twitter.com/anthonypjshawhttps://www.linkedin.com/in/anthonypshaw/https://pybit.es/community (our Slack channel)Every serious Python developer should get a copy of his book:https://realpython.com/products/cpython-internals-book/
Watch the live stream: Watch on YouTube About the show Sponsored by us! Support our work through: Our courses at Talk Python Training pytest book Patreon Supporters Special guest: Marlene Mhangami Brian #1: readme.so Recommended by Johnny Metz This is not only useful, it’s fun Interactively create a README.md file Suggested sections great There are lots of sections though, so really only pick the ones you are willing to fill in. I think this is nicer than the old stand by of “copying the README.md of another project” because that other project might not have some of these great sections, like: Acknowledgements API Reference Authors FAQ Features Logo Roadmap Usage/Examples Running Tests Note, these sections are listed in alphabetical order, not necessarily the right order for how they should go in your README.md Produces a markdown file you can copy or download Also an editor so you can edit right there. (But I’d probably throw together the skeleton with dummy text and edit it in something with vim emulation. Michael #2: Wafer-scale Python via Galen Swint Many new processors with the sole purpose of accelerating artificial intelligence and machine learning workloads. Cerebras, a chip company, built an AI-oriented chip that is 12”x12” (30cm^2) with 850,000 AI cores on board. Another way to look at it is that’s 2.6T transistors vs. my M1’s 0.0016T. Built through TSMC, as so many things seem to be these days. What’s the Python angle here? A key to the design is the custom graph compiler, that takes PyTorch or TensorFlow and maps each layer to a physical part of the chip, allowing for asynchronous compute as the data flows through. Shipping soon for just $3M+. Marlene #3: RAPIDS This is the library I’m currently working on at NVIDIA. I work specifically on CuDF which is a Python GPU DataFrame library for loading, joining, aggregating, filtering, and manipulating tabular data using a DataFrame style API. It mirrors the Pandas API but operations are done on the GPU I gave a talk at PyCon Sweden a few months ago called ‘A Beginners Guide to GPU’s for Pythonista’s’. Here’s an example of how long it takes for pandas vs. cudf to calculate the mean of a group of numbers in a column in a DataFrame: #we'll be calculating the mean of the data in a dataframe (table) import cudf import pandas as pd import numpy as np import time #lets create a data frame using pandas, that has two columns, a and b #we're generating a dataframe where each column contains one hundred million rows #each row is filled with a random integer that can be between 0 to one hundred million pandas_df = pd.DataFrame({"a": np.random.randint(0, 100000000, size=100000000), "b": np.random.randint(0, 100000000, size=100000000)}) #next we want to create a cudf version of this dataframe cudf_df = cudf.DataFrame.from_pandas(pandas_df) #now we'll use timeit to compare the time it takes to calculate the mean #of the numbers in the column "a" of the dataframe. #Lets time Pandas %timeit pandas_df.a.mean() #Lets time CuDF %timeit cudf_df.a.mean() #These were the results I got (might be a little slower if you're using the notebook on Colab) # pandas: 105 ms ± 298 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) #cudf: 1.83 ms ± 4.51 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) You can test this out for right now using the RAPIDS, GPU powered notebook for free on Google Colab. Brian #4: datefinder and dateutil Recommended by Ira Horecka Great calmcode.io video on datefinder Neat use of comprehensions to explore sending a bunch of data into a tool: import datefinder date_strings = [ "March 12 2010", "2010-03-12", "03/12/2010 12:42:12" ] [list(datefinder.find_dates(d)) for d in date_strings] # [[datetime.datetime(2010, 3, 12, 0, 0)], # [datetime.datetime(2010, 3, 12, 0, 0)], # [datetime.datetime(2010, 3, 12, 12, 42, 12)]] Nice focused library, used by 662 projects, according to GitHub datefinder finds dates in strings, then uses dateutil to parse them into datetime objects. dateutil is actually kind of amazing also, great for parsing date strings computing relative delas (next month, last week of the month, etc) relative deltas between date and/or datetimes amazing timezone support comprehensive test suite nice mix of both pytest and unittest. I’ll have to ask Paul Ganssle about that sometime. Michael #5: Cinder - Instagram's performance oriented fork of CPython via Anthony Shaw Instagram's performance oriented fork of CPython. They use a multi-process webserver architecture; the parent process starts, performs initialization work (e.g. loading code), and forks tens of worker processes to handle client requests. The overhead due to copy-on-write from reference counting long-lived objects turned out to be significant. They developed a solution called "immortal instances" to provide a way to opt-out objects from reference counting. "Shadowcode" or “shadow bytecode" is their inline caching implementation. It observes particular optimizable cases in the execution of generic Python opcodes and (for hot functions) dynamically replaces those opcodes with specialized versions. Eager coroutine evaluation: If a call to an async function is immediately awaited, we immediately execute the called function up to its first await. The Cinder JIT is a method-at-a-time custom JIT implemented in C++. And can achieve 1.5-4x speed improvements on many Python performance benchmarks. Strict modules is a few things rolled into one Static Python is an experimental bytecode compiler that makes use of type annotations to emit type-specialized and type-checked Python bytecode. Static Python plus Cinder JIT achieves 7x the performance of stock CPython on a typed version of the Richards benchmark. Marlene #6: PyCon US 2021 PyCon US starts today. Its the largest gathering of the Python community on earth! I’ll be hosting the Diversity and Inclusion Work Group Meet and Greet. I recently became the chair of this WG, which focuses on helping increase global diversity and inclusion in the python community. We’ll be going live on the main stage at PyCon on Saturday 15 May at 12pm EST. There will be lots of time for discussion, so I hope to see some of you there! I’ll also be hosting the PSF EMEA members meeting, which will be on Saturday at 10am CAT. You can register on the Meet up page or watch the livestream on the PSF Youtube channel. You can also find me in the PSF booth on Friday and Saturday morning, if you’d like to meet there! Some other talks I’m looking forward to attending are: Python Performance at Scale - Making Python Faster at Instagram More Fun With Hardware and CircuitPython - IoT, Wearables, and more! Large Scale Data Validation (with Spark and Dask) Registration will be open all through the conference, so if you haven’t yet you can register here And of course all the keynotes this year! Extras Michael Keep your fork in sync at GitHub Flask 2.0 is out! (Just interviewed David and Phil for Talk Python) (thanks Adam Parkin) New Major Versions Released! Flask 2.0, Werkzeug 2.0, Jinja 3.0, Click 8.0, ItsDangerous 2.0, and MarkupSafe 2.0 Brian Lots of great feedback about last weeks Test & Code interview with Brett Cannon about packaging. I’m glad it was helpful to people. This week I’m talking with Ryan Howard about Playwright for automated browser testing. Did you know we have 71 patrons on patreon? So cool. You too can support the show at patreon.com/pythonbytes Marlene If you’d like to connect you can find me on twitter @marlene_zw You can also check out my site marlenemhangami.com Joke
Watch the live stream: Watch on YouTube About the show Sponsored by us! Support our work through: Our courses at Talk Python Training pytest book Patreon Supporters Special guest Guy Royse Brian #1: How to make an awesome Python package in 2021 Anton Zhiyanov, @ohmypy Also thanks John Mitchell, @JohnTellsAll for posting about it. Great writing taking you through everything in a sane order. Stubbing a project with just .gitignore and a directory with a stub __init__.py. Test packaging and publishing use flit init to create initial pyproject.toml set up your ~/.pypirc file publish to the test repo Make the real thing make an implementation publish Extras Adding README.md & CHANGELOG.md and updating pyproject.toml to include README.md and a Python version selector. Adding linting and testing with pytest, tox, coverage, and others Building in the cloud with GH Actions, Codecov, Code Climate Adding badges Task automation with a Makefile Publishing to PyPI from a GH Action Missing (but possibly obvious): GitHub project Checking your project name on PyPI early Super grateful for: Do all of this early in the project Using flit publish --repository pypitest and spelling out how to set up a ~/.pypirc file. Start to finish workflow Example project with all filled out project files Michael #2: Kubestriker Kubestriker performs numerous in depth checks on kubernetes infra to identify the security misconfigurations Focuses on running in production and at scale. kubestriker is Platform agnostic and works equally well across more than one platform such as self hosted kubernetes, Amazon EKS, Azure AKS, Google GKE etc. Current Capabilities Scans Self Managed and cloud provider managed kubernetes infra Reconnaissance phase checks for various services or open ports Performs automated scans incase of insecure, readwrite or readonly services are enabled Performs both authenticated scans and unauthenticated scans Scans for wide range of IAM Misconfigurations in the cluster Scans for wide range of Misconfigured containers Scans for wide range of Misconfigured Pod Security Policies Scans for wide range of Misconfigured Network policies Scans the privileges of a subject in the cluster Run commands on the containers and streams back the output Provides the endpoints of the misconfigured services Provides possible privilege escalation details Elaborative report with detailed explanation Guy #3: wasmtime WebAssembly runtime with support for: Python, Rust, C, Go, .NET Documentation here: https://docs.wasmtime.dev/ Supports WASI (Web Assembly System Interface): WASI supports IO operations—it does for WebAssembly what Node.js did for JavaScript Brian #4: Depend-a-lot-bot Anthony Shaw, @anthonypjshaw A bot for GitHub that automatically approves + merges PRs from dependabot and PyUp.io when they meet certain criteria: All the checks are passing The package is on a safe-list (see configuration) Example picture shows an auto approval and merge of a tox version update, showing “This PR looks good to merge automatically because tox is on the save-list for this repository”. Configuration in a .yml file. I learned recently that most programming jobs that can be automated eventually devolve into configuring a yml file. Michael #5: Supreme Court sides with Google in API copyright battle with Oracle The Supreme Court has sided with Google in its decade-long legal battle with Oracle over the copyright status of application programming interfaces. The ruling means that Google will not owe Oracle billions of dollars in damages. It also has big implications for the broader software industry The ruling heads off an expected wave of lawsuits over API copyrights. The case dates back to the creation of the Android platform in the mid-2000s. Google independently implemented the Java API methods, but to ensure compatibility, it copied Java's method names, argument types, and the class and package hierarchy. Over a decade of litigation, Google won twice at the trial court level, but each time, the ruling was overruled by the Federal Circuit appeals court. The case finally reached the Supreme Court last year. Writing for a six-justice majority, Justice Stephen Breyer held that Google's copying of the Java API calls was permissible under copyright's fair use doctrine. Guy #6: RedisAI Module for Redis that add AI capabilities Turns Redis into a model server: Supports TF, PyTorch, and ONNX models Adds the TENSOR data type ONNX + Redis has positive architectural implications Extras Michael git for Windows JupyterLab reaches v3 (via via Allan Hansen) Why not support Python letter by Brian Skinn Django 3.2 is out & is LTS PyCharm 2021.1 just dropped with Code With Me Brian The PSF is hiring a Developer-in-Residence to support CPython! Joke Vim Escape Rooms Happiness -
Watch the live stream: Watch on YouTube About the show Sponsored by us! Special guest: Micaela Reyes Brian #1: Number One, that's "retract plank," not "remove plank." Yanking vs removing versions on PyPI https://twitter.com/nedbat/status/1376901333958201352?s=20 https://pypi.org/help/#yanked see also https://doughellmann.com/posts/so-youve-released-a-broken-package-to-pypi-what-do-you-do-now/ Michael #2: SQLAlchemy 1.4.0 Released Exciting: 1st release to properly support an async API Has a new select() + execute() rather than session.query() API Intended to unify Core and ORM. See new vs. old API compared. Requires aiosqlite for async API + SQLite: conn_str = 'sqlite+aiosqlite:///filename' Micaela #3: django-tenants by Tom Turner Multi-tenancy Implementation for Django (typically for SaaS websites e.g. Shopify) currently on v3.2.1 (Aug 2020) release Requirements: Django 2 and PostgreSQL It was largely based on django-tenant-schemas library Data Architecture: shared database, separate schema for each tenant Domain setup / URL routing for root and per tenant: Examples: http://my-domain.com:8000/ http://tenant.my-domain.com:8000/ http://tenant2.my-domain.com:8000/ Possible Use-cases: a hospital with different branches restaurant franchise with different branches Possible Limitations: You can’t use the normal migration commands (python manage.py migrate_schemas instead of python manage.py migrate) Reports - when you need to create a report regarding all the clients/tenants, tenant data will be on separate schemas see also: How to get Django Tenants up and Running Brian #5: pre-commit ci pre-commit is “a framework for managing and maintaining multi-language pre-commit hooks.” Hooks can be run during commits, but also hooked other events, such as merge, push, after switching branches, etc. Even if you run pre-commit yourself, it’d be nice to make sure all hooks are run by people submitting pull requests. pre-commit ci *is a service that “enforces that these issues are discovered (which is opt-in for each developer's workflow via *pre-commit) but also fixes the issues automatically, letting developers focus their time on more valuable problems.” Michael #4: Snyk (Python) Package Advisor via David Smit Provides package health score, built up from Popularity Maintenance Security Community Code of conduct and related metrics Number of releases, commits, maintainers, age, etc. Lots of nice graphs and ways you can contribute Micaela #6: PyWebIO by Wang Weimin Allows you build simple web applications or browser-based GUI applications without the need to write HTML and JavaScript. Has input and output modules Based on tornado Possible Use-cases: Hobby projects - for people who know how to write Python code but want to do away with JavaScript Could be a good teaching tool - ex. if you’re teaching kids or beginners and you want to make them appreciate the concept of input and output Possible Limitation: once you need to style your HTML, it might be a bit difficult to do so since it’s tightly coupled with the Python code Extras Michael absolufy-imports by Marco Gorelli Anthony Shaw actually made a Beanie Baby in the terminal within a day of the last episode! PHP supply chain hack Brian packages: pytest-yuk, pytest-srcpaths, pytest-check Micaela Last day of March membership drive for the PSF https://twitter.com/ThePSF/status/1377000184375296003 Joke: Commenting your code
Sponsored by Linode! pythonbytes.fm/linode Special guest: Greg Herrera YouTube live stream for viewers: Watch on YouTube Michael #1: boto type annotations via Michael Lerner boto3's services are created at runtime IDEs aren't able to index its code in order to provide code completion or infer the type of these services or of the objects created by them. Type systems cannot verify them Even if it was able to do so, clients and service resources are created using a service agnostic factory method and are only identified by a string argument of that method. boto3_type_annotations defines stand in classes for the clients, service resources, paginators, and waiters provided by boto3's services. Example with “bare” boto3: Example with annotated boto3: Brian #2: How to have your code reviewer appreciate you By Michael Lynch Suggested by Miłosz Bednarzak Actual title “How to Make Your Code Reviewer Fall in Love with You” but
Catch the video edition live stream on YouTube: Recording out here. Sponsored by us! Support our work through: Our courses at Talk Python Training Test & Code Podcast Patreon Supporters Special guest: Anthony Shaw Be part of the episode by subscribing and “smashing that bell” over at pythonbytes.fm/youtube Michael #1: Django Ledger Project by Miguel Sanda The mission is to provide free and open source accounting software that could easily replace commercial alternatives like QuickBooks. Django Ledger supports: Chart of Accounts. Financial Statements (Income Statement & Balance Sheets). Automatic financial ratio & insight calculations. Multi tenancy. Hierarchical entity management. Self-contained Ledgers, Journal Entries & Transactions. Financial Activities Support (operational/financial/investing). Basic OFX & QFX file import. Bills & Invoices with optional progressible functionality. Basic navigational templates. Entity administration & entity manager support. Bank Accounts. Not quite ready for production. This project is actively looking for contributors. Any financial and/or accounting experience is a big plus. If you have prior accounting experience and want to contribute, don't hesitate to contact. Browse the screenshots on the github repo. Brian #2: Flask-Meld: simple JavaScript interactive features without all of the JavaScript. Flask-Meld article with example Michael Abrahamsen, @MikeAbrahamsen working example, code for example It seems really zippy. Definitely gonna try this. Similar project for Django: django-unicorn Adam Hill, @adamghill todo example Anthony #3: Bitwise operators in Python (RealPython) Article by Bartosz Zaczyński Particularly useful for the enum.IntFlag and enum.Flag classes in the stdlib since 3.7 >>> class Color(Flag): ... RED = auto() ... BLUE = auto() ... GREEN = auto() ... WHITE = RED | BLUE | GREEN Michael #4: Why should you use an ORM (Object Relational Mapper)? You may have heard you should use an ORM, but why? To get a better understanding of how ORMs work, it’s helpful to work through the kind of problems they can solve. Data modeled as classes is great but has some shortcomings How do you query, filter, sort it? How do you store it? Classes live in memory only and pickling isn’t ideal for many reasons There is also concurrency, transactional operations/atomiticity Enter the DB But plain SQL is error prone (did you refactor that name? oops) Plain SQL has code written within another language (SQL within Python, tools help but still) Plain SQL has potential security issues (unless you use parameters) ORMs ORMs are libraries that sit between the SQL database world and your object-oriented programming language world. For all intents and purposes, they are an abstraction layer that allows, among other things, for the translation of Python to SQL. A cycle is formed Define our models in the Python world as objects the ORM layer translates those models to SQL statements with SQL types to create tables and columns. In our application, we instantiate objects from those models, which creates rows in the aforementioned tables. Finally, when we want those objects back, we use Python code to retrieve them, which triggers the ORM layer to create the necessary query to retrieve the rows from the database. Then, the ORM layer takes the resulting rows and maps them back to objects. And you get migrations Brian #5: sqlite-utils: a Python library and CLI tool for building SQLite databases Simon Willison, @simonw “sqlite-utils is a combination Python library and command-line tool I’ve been building over the past six months which aims to make creating new SQLite databases as quick and easy as possible.” CLI for sqlite Run queries and output JSON, CSV, or tables analyzing tables inserting data creating, dropping, transforming tables creating indexes searching … Python API for using as a library way easier interaction with sqlite. import sqlite_utils db = sqlite_utils.Database("demo_database.db") # This line creates a "dogs" table if one does not already exist: db["dogs"].insert_all([ {"id": 1, "age": 4, "name": "Cleo"}, {"id": 2, "age": 2, "name": "Pancakes"} ], pk="id") sqlite-utils docs Anthony #6: Online conferences are not working for me. But this was a good talk, “What the struct?!” by Zachary Anglin at the Pyjamas conference. Explains the struct libraries macro-language for converting binary data structures into Python native types (and vice versa) https://docs.python.org/3/library/struct.html#format-characters Really nice if you want to programmatically edit/read binary structure (combining with the bitwise operators). If you’re getting into this topic. Save-game hacking is an interesting place to start. I use SynalizeIT! /Synalysis as a binary data grammar explorer. It has some example save game formats https://www.synalysis.net/formats.xml Its also great for hacking/CTF. https://youtu.be/QT_NAk_peHQ?t=7130 Extras Brian: Resurrecting Python PDX West as a virtual lunchtime event. January is planned for January 14, 2021 Michael: Did a FastAPI webcast people can check out. M1 life is getting better and better Anthony: From February 1 I’ll be the new Python Open Source advocate at Microsoft, working with Nina Zacharenko Give us a quick update on Pyjion + .NET Core? Jokes: https://twitter.com/lk012/status/1334390836172378113
Sponsored by us! Support our work through: Our courses at Talk Python Training Test & Code Podcast Patreon Supporters Michael #1: Running Python on .NET 5 by Anthony Shaw Talked about pyjion way back when on episode 49 with Brett Cannon. .NET 5 was released on November 10, 2020. It is the cross-platform and open-source replacement of the .NET Core project and the .NET project that ran exclusively on Windows since the late 90’s. See the conference about it if you want to go deeper. Performance: I just saw a SO post about someone complaining their Python was 31x slower than C#. The most common way around this performance barrier is to compile Python extensions from C or using something like Cython. .NET 5 CLR comes bundled with a performant JIT compiler (codenamed RyuJIT) that will compile .NETs IL into native machine instructions on Intel x86, x86-64, and ARM CPU architectures. Pyjion is a project to replace the core execution loop of CPython by transpiling CPython bytecode to ECMA CIL and then using the .NET 5 CLR to compile that into machine code. It then executes the machine-code compiled JIT frames at runtime instead of using the native execution loop of CPython. A few releases of Python ago (CPython specifically, the most commonly used version of Python) in 3.7 a new API was added to be able to swap out “frame execution” with a replacement implementation. This is otherwise known as PEP 523. This extension uses the same standard library as Python 3.9. Will this be compatible with my existing Python code? What about C Extensions? The short answer is- if your existing Python code runs on CPython 3.9 – yes it will be compatible. Tested against the full CPython “test suite” on all platforms. In fact, it was the first JIT ever to pass the test suite. Is this faster? The short answer a little, but not by much (yet). see also: https://twitter.com/anthonypjshaw/status/1328457723608928256?s=20 Brian #2: PEP 621 -- Storing project metadata in pyproject.toml Progress on standardizing what goes into pyproject.toml Authors Brett Cannon, Paul Ganssle, Pradyun Gedam, Sébastien Eustace (of poetry), Thomas Kluyver (of flit), Tzu-Ping Chung Motivators of this PEP are: Encourage users to specify core metadata statically for speed, ease of specification, unambiguity, and deterministic consumption by build back-ends Provide a tool-agnostic way of specifying metadata for ease of learning and transitioning between build back-ends Allow for more code sharing between build back-ends for the "boring parts" of a project's metadata Doesn’t change any existing core metadata Doesn’t attempt to standardize all possible metadata Included in table named [project]: name version description readme requires-python license authors/maintainers keywords classifiers urls entry points dependencies/optional-dependencies dynamic There’s an example in the PEP that helps clear things up Many items have synonyms specified for flit/poetry/setuptools (presumably for backward compatibility) Michael #3: GitHub revamps copyright takedown policy after restoring YouTube-dl In October following a DMCA complaint from the Recording Industry Association of America (RIAA) it was taken down at GitHub. Citing a letter from the Electronic Frontier Foundation (the EFF), GitHub says it ultimately found that the RIAA’s complaint didn’t have any merit. The RIAA argued the tool ran afoul of section 1201 of the US copyright law by giving people the means to circumvent YouTube’s DRM. the EFF dissects the RIAA’s claims, highlighting where the organization had either misinterpreted the law or how the code of YouTube-dl works. “Importantly, YouTube-dl does not decrypt video streams that are encrypted with commercial DRM technologies, such as Widevine, that are used by subscription videos sites, such as Netflix,” the organization points out when it comes to the RIAA’s primary claim. GitHub is implementing new policies to avoid a repeat of a repeat situation moving forward. First, it says a team of both technical and legal experts will manually evaluate every single section 1201 claim. If the company’s technical and legal teams ultimately find any issues with a project, GitHub will give its owners the chance to address those problems before it takes down their work. GitHub is establishing a $1 million legal defense fund for developers. Sidebar: EFF has just launched How to Fix the Internet, a new podcast mini-series that examines potential solutions to six ills facing the modern digital landscape. Brian #4: Install & Configure MongoDB on the Raspberry Pi Mark Smith Definitely a “wow, I didn’t know you could do that” article. Tutorial walks through Installing 64 bit Ubuntu Server on a Raspberry Pi Configure wifi Install MongoDB on Pi Set up a user account, to safely expose MongoDB on a home network. Now you’ve got a MongoDB server in your house. So cool Michael #5: Extra! extra! extra!, hear all about it! Follow up on my critique of things like SQL & CSS put next to Python and Java. Maybe best to grab the conversation from here. Guido joins Microsoft, why? People seem to see this as a positive for sure. But they checked him out! New code editor roaming the streets: Nova from Panic. Two thumbs up on Big Sur and now waiting on the Mac Mini M1. Brian #6: A Python driven AI Stylist Inspired by Social Media Dale Markowitz A bunch of Google tools (cloud storage, firebase, cloud vision api, product search api) Some React for front end Python to batch script General oversimplified process: photos from social media for inspiration photos of everything in your closet, multiple of each item use AI suggest outfits from your closet that match inspiration photos Ok. The process is really more of a promo for Google AI products, and not so much about Python, but it’s a cool “look what you can do with software” kinda thing. Also, many of the tools used by online retail, like “similar products” and such, are available to lots of people now, and that’s cool. Joke: Back to the [dev] future!
Sponsored by Techmeme Ride Home podcast: pythonbytes.fm/ride Special guest: Steve Dower - @zooba Brian #1: Making Enums (as always, arguably) more Pythonic “I hate enums” Harry Percival Hilarious look at why enums are frustrating in Python and a semi-reasonable workaround to make them usable. Problems with enums of strings: Can’t directly compare enum elements with the values Having to use .value is dumb. Can’t do random choice of enum values Can’t convert directly to a list of values If you use IntEnum instead of Enum and use integer values instead of strings, it kinda works better. Making your own StringEnum also is better, but still doesn’t allow comparison. Solution: class BRAIN(str, Enum): SMALL = 'small' MEDIUM = 'medium' GALAXY = 'galaxy' def __str__(self) -> str: return str.__str__(self) Derive from both str and Enum, and add a *__str(self)__* method. Fixes everything except random.choice(). Michael #2: Python 3.10 will be up to 10% faster 4.5 years in the making, from Yury Selivanov work picked up by Pablo Galindo, Python core developer, Python 3.10/3.11 release manager LOAD_METHOD, CALL_METHOD, and LOAD_GLOBAL improved “Lot of conversations with Victor about his PEP 509, and he sent me a link to his amazing compilation of notes about CPython performance. One optimization that he pointed out to me was LOAD/CALL_METHOD opcodes, an idea first originated in PyPy.” There is a patch that implements this optimization Based on: LOAD_ATTR stores in its cache a pointer to the type of the object it works with, its tp_version_tag, and a hint for PyDict_GetItemHint. When we have a cache hit, LOAD_ATTR becomes super fast, since it only needs to lookup key/value in type's dict by a known offset (the real code is a bit more complex, to handle all edge cases of descriptor protocol etc). Steve #3: Python 3.9 and no more Windows 7 PEP 11 -- Removing support for little used platforms | Python.org Windows 7 - Microsoft Lifecycle | Microsoft Docs Default x64 download Brian #4: Writing Robust Bash Shell Scripts David Pashley Some great tips that I learned, and I’ve been writing bash scripts for decades. set -u : exits your script if you use an uninitialized variable set -e : exit the script if any statement returns a non-true return value. Prevents errors from snowballing. Expect the unexpected, like missing files, missing directories, etc. Be prepared for spaces in filenames. if [ "$filename" = "foo" ]; Using trap to handle interrupts, exits, terminal kills, to leave the system in a good state. Be careful of race conditions Be atomic Michael #5: Ideas for 5x faster CPython Twitter post by Anthony Shaw calling attention to roadmap by Mark Shannon Implementation plan for speeding up CPython: The overall aim is to speed up CPython by a factor of (approximately) five. We aim to do this in four distinct stages, each stage increasing the speed of CPython by (approximately) 50%: 1.5**4 ≈ 5 Each stage will be targeted at a separate release of CPython. Stage 1 -- Python 3.10: The key improvement for 3.10 will be an adaptive, specializing interpreter. The interpreter will adapt to types and values during execution, exploiting type stability in the program, without needing runtime code generation. Stage 2 -- Python 3.11: Improved performance for integers of less than one machine word. Faster calls and returns, through better handling of frames. Better object memory layout and reduced memory management overhead. Stage 3 -- Python 3.12 (requires runtime code generation): Simple "JIT" compiler for small regions. Stage 4 -- Python 3.13 (requires runtime code generation): Extend regions for compilation. Enhance compiler to generate superior machine code. Wild conversation over here. One excerpt, from Larry Hastings: Speaking as the Gilectomy guy: borrowed references are evil. The definition of the valid lifetime of a borrowed reference doesn't exist, because they are a hack (baked into the API!) that we mostly "get away with" just because of the GIL. If I still had wishes left on my monkey's paw I'd wish them away (1). (1) Unfortunately, I used my last wish back in February, wishing I could spend more time at home.* Steve #6: CPython core developer sprints Hosted by pythondiscord.com https://youtu.be/gXMdfBTcOfQ - Core dev Q&A Extras Brian: Tools I found recently that are kinda awesome in their own way - Brian mcbroken.com - Is the ice cream machine near you working? just a funny single purpose website vim-adventures.com - with a dash. Practice vim key bindings while playing an adventure game. Super cool. Joke: Hackobertfest 2020 t-shirt https://twitter.com/McCroden/status/1319646107790704640 5 Most Difficult Programming Languages in the World (Not really long enough for a full topic, but funny. I think I’ll cut short the last code example after we record) suggested by Troy Caudill Author: Lokajit Tikayatray malboge, intercal, brainf*, cow, and whitespace whitespace is my favorite: “Entire language depends on space, tab, and linefeed for writing any program. The Whitespace interpreter ignores Non-Whitespace characters and considers them as code comments.” Intercal is kinda great in that One thing I love about this article is that the author actually writes a “Hello World!” for each language. Examples of “Hello World!” malboge (=
What does a "Global Senior Vice President of Talent Transformation and Innovation" do? I have no clue! But I can tell you this: it has nothing to do with coding. I spoke with Anthony Shaw. Anthony is a "Python Foundation Software Fellow". To become a Fellow, you need to contribute a lot to the Python ecosystem and be recognized by your peers to be nominated. Anthony contributes with various open source projects that can be found on his GitHub repository. Anthony is an English expat living in the beautiful Avoca Beach in Australia. I was curious about the connection between his job and coding. I found out that there is not much. But it didn't stop Anthony from being not only enthusiastic about coding but also being a great coder! We spoke about his passion for Python and what motivated him to start contributing to open source. Listen to this conversation to understand why Anthony says that if the thought of making a living as a developer doesn't excite you, but you like technology and programming, there are so many other options available to express yourself as a coder. Full show notes and links: https://SoloCoder.com/59
Sponsored by us! Support our work through: Our courses at Talk Python Training Test & Code Podcast Michael #1: watchdog via Prayson Daniel Python API and shell utilities to monitor file system events. Example: observer = Observer() observer.schedule(event_handler, path, recursive=True) observer.start() Watchdog comes with an optional utility script called watchmedo try $ watchmedo log and see what happens in that folder. Why Watchdog? Compared to other similar libs Brian #2: Status code 418 Thanks Andy Howe for the suggestion Python 3.9 rc1 is out. One nice enhancement that has made it into 3.9, a fix for http library missing HTTP status code 418 “I’m a teapot”. https://bugs.python.org/issue39507 Title: http library missing HTTP status code 418 "I'm a teapot" See also status code 418 is also supported by HTCPCP, Hyper Text Coffee Pot Control Protocol, https://tools.ietf.org/html/rfc2324 418 I'm a teapot Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout. The only other unique HTCPCP code is 406 406 Not Acceptable … In HTCPCP, this response code MAY be returned if the operator of the coffee pot cannot comply with the Accept-Addition request. Unless the request was a HEAD request, the response SHOULD include an entity containing a list of available coffee additions. This has been going on since 1998 and I'm just now hearing about it. A nice reference site: httpstatuses.com References https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol https://cstrobbe.github.io/WC3/TR/2008/RFC-htcpcp-in-rdf-20080401/ https://cstrobbe.github.io/WC3/TR/2008/RFC-htcpcp-in-rdf-20080401/ Michael #3: pydantic’s new Validation decorator via Andy Shapiro Built-in type checking for any function via a decorator easy to add for any public methods in a package pydantic uses lots of cython under the hood so it should be fast.... The validate_arguments decorator allows the arguments passed to a function to be parsed and validated using the function's annotations before the function is called. Under the hood this uses the same approach of model creation and initialization; it provides an extremely easy way to apply validation to your code with minimal boilerplate. Example: from pydantic import validate_arguments, ValidationError @validate_arguments def repeat(s: str, count: int, *, separator: bytes = b'') -> bytes: b = s.encode() return separator.join(b for _ in range(count)) a = repeat('hello', 3) print(a) #> b'hellohellohello' b = repeat('x', '4', separator=' ') print(b) #> b'x x x x' try: c = repeat('hello', 'wrong') except ValidationError as exc: print(exc) """ 1 validation error for Repeat count value is not a valid integer (type=type_error.integer) """ Brian #4: Building Python Extension Modules in Assembly Anthony Shaw From twitter announcement: “After a series of highly questionable life decisions, my Python extension written in pure assembly is now on PyPI. https://pypi.org/project/pymult/ it required writing an Assembly extension for distutils, I also added GitHub Actions support so its running CI/CD and testing with pytest”. A proof-of-concept to demonstrate how you can create a Python Extension in 100% assembly. Demonstrates: How to write a Python module in pure assembly How to write a function in pure assembly and call it from Python with Python objects How to call the C API to create a PyObject and parse PyTuple (arguments) into raw pointers How to pass data back into Python How to register a module from assembly How to create a method definition in assembly How to write back to the Python stack using the dynamic module loader How to package a NASM/Assembly Python extension with distutils The simple proof-of-concept function takes 2 parameters, >>> import pymult >>> pymult.multiply(2, 4) 8 May need a few more test cases: >>> pymult.multiply(2, 3) 6 >>> pymult.multiply(-2, -3) 6 >>> pymult.multiply(-2, 3) 4294967290 Also, clearly Anthony has too much time on his hands. Just saying. Michael #5: easy property via Ruud van der Ham The easy_property module, developed by me, offers a more intuitive way to define a Python property with getter, setter, deleter, getter_setter and documenter decorators. Normally when you want to define a property that has a getter and a setter, you have to do something like Class Demo: def __init__(self, val): self.a = val @property def a(self): return self._a @a.setter def a(self, val): self._a = val IMHO, the @a.setter is a rather ugly decorator, and hard to remember. And there's no way to not define the getter. With the easy_property module, one can use the decorators getter setter deleted as in: Class Demo: def __init__(self, val): self.a = val @getter def a(self): return self._a @setter def a(self, val): self._a = val @deleter def a(self): print('delete') del self._a In contrast with an ordinary property, the order of definition of getter, setter and deleter is not important. And it is even possible to define a setter only (without a getter), just in case. With easy_property, you can even create a combined getter/setter decorator: Class Demo: def __init__(self, val): self.a = val @getter_setter def a(self, val=None): if val is None: return self._a self._a = val Finally, it is possible to add a docstring to the property, with the @documenter decorator: Class Demo: def __init__(self, val): self.a = val @getter def a(self): return self._a @documenter: def a(self): return "this is the docstring of Demo.a" Although this might not be always a good solution, I think in many cases this will make it easier and more intuitive to define properties. Brian #6: Non Blocking Assertion Failures with pytest-check Ryan Howard wrote an article about a project of mine on the TestProject blog. I think it’s a first that someone else wrote an article about something I made. So that’s cool. Most tests do the “check” part with assert statements. The problem is assert stops after the first failure and you often want to check lots of stuff, and you want to see all the failures. Ryan has a good example with checking web pages using selenium and a simple example of wanting to check both the content of an element on the page, and the url. Cool use of pytest-check See also: pytest-check This plugin started as a discussion I started online in 2015 with a blog post: Delayed assert / multiple failures per test. Extras: Brian PSA: There are no capital letters in pytest, even if it begins a sentence. Michael PyMC core devs, we are currently planning the first ever PyMCon (pronounce "PyMC ON", because "it is oooon" ;))! This is an asynchronous-first conference for the Bayesian community, with three goals: Create a space and time for community members to meet each other and interact Record and organize the expertise and experience around PyMC Help folks find ways to contribute to PyMC, authentic to themselves urlify! https://twitter.com/mkennedy/status/1292955438552506370 get it on github at https://github.com/mikeckennedy/urlify Thumbnails in the video player at talk python training Joke: XKCD git - xkcd.com/1597 “I used to do low-level programming. Then a product I bought told me, "No assembly required." Since then, I've been coding in Python.” - From Rueven Lerner, Inspired by Anthony Shaw
Have you wanted to get started with testing in Python? Maybe you feel a little nervous about diving in deeper than just confirming your code runs. What are the tools needed and what would be the next steps to level up your Python testing? This week on the show we have Anthony Shaw to discuss his article on this subject. Anthony is a member of the Real Python team and has written several articles for the site.
Talk Python To Me - Python conversations for passionate developers
The debate about whether Python is fast or slow is never-ending. It depends on what you're optimizing for: Server CPU consumption? Developer time? Maintainability? There are many factors. But if we keep our eye on pure computational speed in the Python layer, then yes, Python is slow. In this episode, we invite Anthony Shaw back on the show. He's here to dig into the reasons Python is computationally slower than many of its peer languages and technologies such as C++ and JavaScript. Links from the show Anthony's PyCon Talk: youtube.com N-body problem example: github.com HPy project: github.com Austin profiler: github.com Prior episodes: #240: A guided tour of the CPython source: talkpython.fm #214: Dive into CPython 3.8: talkpython.fm #168: 10 Python security holes: talkpython.fm Sponsors Brilliant Sentry Error Monitoring, Code TALKPYTHON Talk Python Training
Sponsored by DigitalOcean: pythonbytes.fm/digitalocean - $100 credit for new users to build something awesome. Michael #1: Ubuntu 20.04 is out! Next LTS support version since 26th April 2018 (18.04). Comes with Python 3.8 included! Already upgraded all our servers, super smooth. Kernel has been updated to the 5.4 based Linux kernel, with additional support for Wireguard VPN, AUFS5, and improved support for IBM, Intel, Raspberry Pi and AMD hardware. Features the latest version of the GNOME desktop environment. Brings support for installing an Ubuntu desktop system on top of ZFS. 20.04 already an option on DigitalOcean ;) Brian #2: Working with warnings in Python (Or: When is an exception not an exception?) Reuven Lerner Exceptions, the class hierarchy of exceptions, and warnings. “… most of the time, warnings are aimed at developers rather than users. Warnings in Python are sort of like the “service needed” light on a car; the user might know that something is wrong, but only a qualified repairperson will know what to do. Developers should avoid showing warnings to end users.” Python’s warning system …: It treats the warnings as a separate type of output, so that we cannot confuse it with either exceptions or the program’s printed text, It lets us indicate what kind of warning we’re sending the user, It lets the user indicate what should happen with different types of warnings, with some causing fatal errors, others displaying their messages on the screen, and still others being ignored, It lets programmers develop their own, new kinds of warnings. Reuven goes on to show how to use warnings in your code. using them creating custom warnings filtering Michael #3: Safer file writer pip installable, see the article and the repo too. Consider this code: with open(filename, 'w') as fp: json.dump(data, fp) It’s using with, so it’s good right? Well the file itself may be overwritten and maybe corrupted With safer, you write almost identical code: with safer.open(filename, 'w') as fp: json.dump(data, fp) Now if json.dump() throws an exception, the original file is unchanged, so your important data file lives to see another day. The actual 28 lines of code is pretty interesting: https://github.com/rec/safer/blob/v1.0.0/safer.py#L70-L97 Brian #4: codespell codespell : Fix common misspellings in text files. It's designed primarily for checking misspelled words in source code, but it can be used with other files as well. I got a cool pull request against the cards project to add a pre-commit hook to run codespell. (Thanks Christian Clauss) codespell caught a documentation spelling error in cards, where I had spelled “arguments” as “arguements”. Oops. Spelling errors are annoying and embarrassing in code and comments, and distracting. Also hard to deal with using traditional spell checkers. So super glad this is a thing. Michael #5: Austin profiler via Anthony Shaw Python frame stack sampler for CPython Profiles CPU and Memory! Why Austin? Written in pure C Austin is written in pure C code. There are no dependencies on third-party libraries. Just a sampler - fast: Austin is just a frame stack sampler. It looks into a running Python application at regular intervals of time and dumps whatever frame stack it finds. Simple output, powerful tools Austin uses the collapsed stack format of FlameGraph that is easy to parse. You can then go and build your own tool to analyse Austin's output. You could even make a player that replays the application execution in slow motion, so that you can see what has happened in temporal order. Small size Austin compiles to a single binary executable of just a bunch of KB. Easy to maintain Occasionally, the Python C API changes and Austin will need to be adjusted to new releases. However, given that Austin, like CPython, is written in C, implementing the new changes is rather straight-forward. Creates nice flame graphs The Austin TUI is nice! Web Austin is yet another example of how to use Austin to make a profiling tool. It makes use of d3-flame-graph to display a live flame graph in the web browser that refreshes every 3 seconds with newly collected samples. Austin output format can be converted easily into the Speedscope JSON format. You can find a sample utility along with the TUI and Austin Web. Brian #6: Numbers in Python Moshe Zadka A great article on integers, floats, fractions, & decimals Integers They turn into floats very easily, (4/3)*3 → 4.0, int → float Floats don’t behave like the floating point numbers in theory don’t obey mathematical properties subtraction and addition are not inverses 0.1 + 0.2 - 0.2 - 0.1 != 0.0 addition is not associative My added comment: Don’t compare floats with ==, use pytest.approx or other approximation techniques. Fractions Kinda cool that they are there but be very careful about your input Algorithms on fractions can explode in time and to some extent memory. Generally better to use floats Decimals Good for financial transactions. Weird dependence on a global state variable, the context precision. Safer to use a local context to set the precision locally >>> with localcontext() as ctx: ... ctx.prec = 10 ... Decimal(1) / Decimal(7) ... Decimal('0.1428571429') See also fractions in std lib decimals in std lib What Every Computer Scientist Should Know About Floating-Point Arithmetic Extras: Brian: python 3.9.0a6, now with the new PEG parser for CPython Michael: Keep subscribing over at youtube: pythonbytes.fm/youtube Joke: Unix is user friendly. It's just very particular about who its friends are. (via PyJoke) If you put 1000 monkeys at 1000 computers eventually one will write a Python program. The rest will write PERL. (via @JamesAbel)
Python for Parents or so you want your child to code? Sometimes it just takes a few creative ideas and a short amount of time to make some fun little projects. Sean and Kelly, with the help of Anthony Shaw and his lovely daughters, ‘ Zebra’ and ‘Jaguar’ have a little fun with this topic! The Shaws’ help us to dive into the topic of #pythonicparenting. Together we discuss things that a parent can do to help your child have the same passion for coding as you do. Or at least some interest! Whether you are an experienced coder or just a beginner, you can still find some projects that you can build with your kids at home. We encourage you to have a little fun, enjoy a lot of giggles and make loads of memories with your kids, while learning Python,. Special Guest: Anthony Shaw.
Application security is best designed into a system from the start. Anthony Shaw is doing something about it by creating an editor plugin that actually helps you write more secure application code while you are coding. On today's Test & Code, Anthony and I discuss his security plugin, but also application security in general, as well as other security components you need to consider. Security is something every team needs to think about, whether you are a single person team, a small startup, or a large corporation. Anthony and I also discuss where to start if it's just a few of you, or even just one of you. Topics include: Finding security risks while writing code. What are the risks for your applications. Thinking about attack surfaces. Static and dynamic code analysis. Securing the environment an app is running in. Tools for scanning live sites for vulnerabilities. Secret management. Hashing algorithms. Authentication systems. and Anthony's upcoming cPython Internals book. Special Guest: Anthony Shaw.
Memory surgeons, 3D human tissue printing, space pilot…What jobs are on the horizon and how can you prepare for what’s coming? Anthony Shaw, Director of Talent Management and Development at Dimension Data, is back on the podcast to give us the lowdown. Press play…
Sponsored by DigitalOcean: pythonbytes.fm/digitalocean Brian #1: iterators, generators, coroutines Cool quick read article by Mark McDonnell. Starts with an attempt at a gentle introduction to the iterator protocol (why does everyone think that users need to start with this info?) Muscle through this part or just skim it. Should be an appendix. Generators (start here): functions that use yield Unbound generators: they don’t stop Generator Expressions: Like for v in ("foo" for i in range(5)): … Use parens instead of brackets, otherwise they are like list comprehensions. Specifically: (expression for item in collection if condition) Generators using generators / nested generators : yield from Given bar() and baz() are generators, this works: def foo(): yield from bar() yield from baz() Coroutines are an extension of generators “Generators use the yield keyword to return a value at some point in time within a function, but with coroutines the yield directive can also be used on the right-hand side of an = operator to signify it will accept a value at that point in time.” Then….. coroutine example, some asyncio stuff, … honestly I got lost. Bottom line: I’m still looking for a great tutorial on coroutines that doesn’t explain the iterator protocol (boring!) shows an example NOT using asyncio and NOT a REPL example I want to know how I can make use of coroutines in an actual program (toy ok) where the use of coroutines actually helps the structure and makes it more maintainable, etc. Michael #2: requests-toolbelt A toolbelt of useful classes and functions to be used with requests multipart/form-data encoder - The main attraction is a streaming multipart form-data object, MultipartEncoder. User-Agent constructor - You can easily construct a requests-style User-Agent string SSLAdapter - Allows the user to choose one of the SSL protocols made available in Python's ssl module for outgoing HTTPS connections ForgetfulCookieJar - prevents a particular requests session from storing cookies Brian #3: Pandas Validation We covered Bulwark in episode 162 There are other approaches and projects looking at the same problem. pandas-validation Suggested by Lance “… pandas-validation lets you create a template of what your pandas dataframe should look like and it'll validate the entire dataframe against that template. So if you have a dataframe with first column being strings second column being dates and the third being address, you can use a mixture of built in validate types to ensure your data conforms to that. It will even let you set up some regex and make sure that the data in a column conforms to that regex.” - Lance supports dates, timestamps, numeric values, strings pandera “pandera provides a flexible and expressive API for performing data validation on tidy (long-form) and wide data to make data processing pipelines more readable and robust." “pandas data structures contain information that pandera explicitly validates at runtime. This is useful in production-critical or reproducible research settings. “pandera enables users to: Check the types and properties of columns in a DataFrame or values in a Series. Perform more complex statistical validation. Seamlessly integrate with existing data analysis/processing pipelines via function decorators.” A few different approaches. I can’t really tell from the outside if there is a clear winner or solution that’s working better for most cases. I’d like to hear from listeners which they use, if any. Or if we missed the obvious validation method most people are using. Michael #4: qtpy I have been inspired to check out Qt again, but the libraries and versions a confusing. Provides an uniform layer to support PyQt5, PySide2, PyQt4 and PySide with a single codebase Basically, you can write your code as if you were using PySide2 but import Qt modules from qtpy instead of PySide2 (or PyQt5). Brian #5: pylightxl Viktor Kis submission “A light weight, zero dependency, minimal functionality excel read/writer python library” Well. Reader right now. Writing coming soon. :) Some cool examples in the docs to get you started grabbing data from spreadsheets right away. Features: Zero non-standard library dependencies Single source code that supports both Python37 and Python27. The light weight library is only 3 source files that can be easily copied directly into a project for those that have installation/download restrictions. In addition the library’s size and zero dependency makes pyinstaller compilation small and easy! 100% test-driven development for highest reliability/maintainability with 100% coverage on all supported versions API aimed to be user friendly, intuitive and to the point with no bells and whistles. Structure: database > worksheet > indexing example: db.ws('Sheet1').index(row=1,col=2) or db.ws('Sheet1').address(address='B1') Read excel files (.xlsx, .xlsm), all sheets or selective few for speed/memory management Index cells data by row/col number or address Calling an entire row/col of data returns an easy to use list output: db.ws('Sheet1').row(1) or db.ws('Sheet1').rows Worksheet data size is consistent for each row/col. Any data that is empty will return a ‘’ Michael #6: python-ranges via Aiden Price Continuous Range, RangeSet, and RangeDict data structures for Python Best understood as an example: tax_info = RangeDict({ Range(0, 9701): (0, 0.10, 0), Range(9701, 39476): (970, 0.12, 9700), ... }) income = int(input("What is your income? $")) base, marginal_rate, bracket_floor = tax_info[income] Range and RangeSet objects are mutually compatible for things like union(), intersection(), difference(), and symmetric_difference() Extras: Brian: pytest-check works with pytest-rerunfailures - with other plugins, it may not. - known incompatibility with flaky and retry Michael: Pandas goes 1.0 (via Jeremy Schendel). Just put out a release candidate for 1.0, and will be using SemVer going forward. PyCharm security from Anthony Shaw. Video for Python for Decision Makers webcast is out. Joke: Optimist: The glass is half full. Pessimist: The glass is half empty. Engineer: The glass is twice as large as it needs to be.
Talk Python To Me - Python conversations for passionate developers
You might use Python every day. But how much do you know about what happens under the covers, down at the C level? When you type something like variable = [], what are the byte-codes that accomplish this? How about the class backing the list itself? All of these details live at the C-layer of CPython. On this episode, you'll meet Anthony Shaw. He and I take a guided tour of the CPython source code. After this, you won't have to guess what's happening. You can git-clone the CPython source code and see for yourself. Links from the show Anthony on Twitter: @anthonypjshaw Python on Github: github.com RealPython article: realpython.com Memory management in Python article: rushter.com Dismissing Python Garbage Collection at Instagram: instagram-engineering.com Prior episodes with Anthony #180: What's new in Python 3.7 and beyond: talkpython.fm #168: 10 Python security holes and how to plug them: talkpython.fm #155: Practical steps for moving to Python 3: talkpython.fm #132: Contributing to open source: talkpython.fm Sponsors Linode USF Talk Python Training
More than fifty-five doctors and specialists either misdiagnosed her, or didn’t know how to help her. You’ll want to hang on when you read this one. Sheila Anthony-Shaw experiences: an unceremonious year as a California beauty queen; being slighted by the love of her life days after losing their unborn child; a heartless doctor who rather remove her reproduction organs than address her ruptured appendix, and driving alone across the San Francisco-Oakland Bay Bridge without being able to use the gas, or brake pedals in her car. How she overcame these events—and others—will echo down through the ages. Through her high points and low points, at no point was God not there. You’ll laugh, cry, and gasp. But you’ll also be inspired beyond measure. Join me as I talk about overcoming life adversities and difficulties with a woman who has experienced them first hand, Sheila Anthony Shaw. Join in the conversation at 646-668-8485 and press 1 to be live on air. Or, download Stitcher on your mobile device. Follow us on iTunes. Or, click on the link here: http://tobtr.com/s/11508755.
As we build software projects, complexity and technical debt are bound to creep into our code. To counteract these tendencies it is necessary to calculate and track metrics that highlight areas of improvement so that they can be acted on. To aid in identifying areas of your application that are breeding grounds for incidental complexity Anthony Shaw created Wily. In this episode he explains how Wily traverses the history of your repository and computes code complexity metrics over time and how you can use that information to guide your refactoring efforts.
Anthony Shaw joins Brian to discuss flaky tests and flaky test suites. What are flaky tests? Is it the same as fragile tests? Why are they bad? How do we deal with them? What causes flakiness? How can we fix them? How can we avoid them? Proactively rooting out flakiness Test design GUI tests Sharing solutions Special Guest: Anthony Shaw.
How do you write tests for things that aren’t that easy to write tests for? That question is a possibly terrible summary of a question sent to me by a listener. And to help me start answering that question, I asked a friend of mine to help, Antony Shaw. Of course, different types of applications have different test strategies, so there’s not a universal answer. But I know some of you out there have experience and expertise around how to tackle this problem. Listen to the discussion Anthony and I have about it, and let me know if you have some techniques or tips to add. Special Guest: Anthony Shaw.
Should you learn to code? Anthony Shaw, Director of Learning and Development and coding guru at Dimension Data answers the question and gives us the lowdown on why coding can help you expand your mind and career.
We talk with Anthony Shaw about some of the testing problems facing both DevOps teams, and Agile teams. We also talk about his recent pull request accepted into pytest. Special Guest: Anthony Shaw.
Breakfast of Champions - Episode 3. Brought to you by Peter Bayer and Anthony Shaw. In this episode we talk about the key NFL games in Week 2, Wentz-Winston-Mariota-Carr debate, how valuable Andrew Luck really is, Stafford worth the money. As well as the NCAA Football Week 3 top games/upsets, Texas and Oregon new coaches. Lastly, how the Lakers will fare this year.
Breakfast of Champions - Episode 3. Brought to you by Peter Bayer and Anthony Shaw. In this episode we talk about the key NFL games in Week 2, Wentz-Winston-Mariota-Carr debate, how valuable Andrew Luck really is, Stafford worth the money. As well as the NCAA Football Week 3 top games/upsets, Texas and Oregon new coaches. Lastly, how the Lakers will fare this year.
Jennika Anthony Shaw is a newly qualified Barrister who held the position of Project Manager and Commercial Group Proceedings Coordinator for the Supreme Court of Victoria. Jennika has performance degrees from McGill University and the Manhattan School of Music and built a successful freelance career as a global trotting Cellist before embarking upon the path that would lead her to the law.Jennika shares the story of her realisation that a freelance music career meant a lack of control, limited avenues for personal growth and academic challenge. She was curious to see if a career beyond music was "even possible" and shares how her critical thinking and performance skills have mapped to her new career in law.
Marika Anthony-Shaw is Founder and CEO of Plus 1. Plus 1 is revolutionizing philanthropy and creating new avenues for social and civic engagement through music. By connecting artists, fans and organizations, Plus 1 amplifies collective impact and shows how small actions can lead to change - namely consistent, sustainable and substantive change. If Marika looks familiar to you, you may recognize her as the Viola-weilding touring member of Grammy award-winning band Arcade Fire. For nine years, Marika played her heart out while simultaneously directing and managing the band’s philanthropy and community outreach. During our conversation, Marika will share how she and her fellow band members experienced the incredible energy of thousands of people coming together as well as how they chose to harness and channel it for social good. Captured by the potential of Plus 1 and guided by her musical colleagues and mentor Dr. Paul Farmer, a founder of Partners in Health, Marika dedicated herself to building an independent organization. Plus 1 was founded in 2013. From a small office in Montréal, she and her team empower other artists to partner with their fans to drive awareness, advocacy, and resources for organizations doing proven, measurable work to address inequity and injustice; repair and preserve our planet; and provide sustainable access to healthcare, food supply, education, equal protection under law and within society for all human beings. On the personal-front, Marika's also a strong, whipsmart, and funny working mom and wife. She shares some successes and challenges in trying to keep it all together, especially when she's feeling like it's anything but together. With humor and stories, Marika offers some amazing perspective for the Pinterest-induced imposters and the overwhelmed modern women among us. Outside of work, Marika sits on the Board of Directors of Partners in Health Canada, and on the PIH Board of Trustees in Boston as a volunteer. She frequently speaks about the power of collective impact and philanthropy in the arts, including appearances at C2 Montreal, the Forbes Under 30 Summit, and universities and engagements around the world.
Guest: Anthony Shaw @anthonypjshaw Full show notes are at https://developeronfire.com/podcast/episode-167-anthony-shaw-innovation-and-inspiration
More and more of our applications are running in the cloud and there are increasingly more providers to choose from. The LibCloud project is a Python library to help us manage the complexity of our environments from a uniform and pleasant API. In this episode Anthony Shaw joins us to explain how LibCloud works, the community that builds and supports it, and the myriad ways in which it can be used. We also got a peek at some of the plans for the future of the project.