Podbean logo
  • Discover
  • Podcast Features
    • Podcast Hosting

      Start your podcast with all the features you need.

    • Podbean AI Podbean AI

      AI-Enhanced Audio Quality and Content Generation.

    • Blog to Podcast

      Repurpose your blog into an engaging podcast.

    • Video to Podcast

      Convert YouTube playlists to podcasts, videos to audios.

  • Monetization
    • Ads Marketplace

      Join Ads Marketplace to earn through podcast sponsorships.

    • PodAds

      Manage your ads with dynamic ad insertion capability.

    • Apple Podcasts Subscriptions Integration

      Monetize with Apple Podcasts Subscriptions via Podbean.

    • Live Streaming

      Earn rewards and recurring income from Fan Club membership.

  • Podbean App
    • Podcast Studio

      Easy-to-use audio recorder app.

    • Podcast App

      The best podcast player & podcast app.

  • Help and Support
    • Help Center

      Get the answers and support you need.

    • Podbean Academy

      Resources and guides to launch, grow, and monetize podcast.

    • Podbean Blog

      Stay updated with the latest podcasting tips and trends.

    • What’s New

      Check out our newest and recently released features!

    • Podcasting Smarter

      Podcast interviews, best practices, and helpful tips.

  • Popular Topics
    • How to Start a Podcast

      The step-by-step guide to start your own podcast.

    • How to Start a Live Podcast

      Create the best live podcast and engage your audience.

    • How to Monetize a Podcast

      Tips on making the decision to monetize your podcast.

    • How to Promote Your Podcast

      The best ways to get more eyes and ears on your podcast.

    • Podcast Advertising 101

      Everything you need to know about podcast advertising.

    • Mobile Podcast Recording Guide

      The ultimate guide to recording a podcast on your phone.

    • How to Use Group Recording

      Steps to set up and use group recording in the Podbean app.

  • All Arts Business Comedy Education
  • Fiction Government Health & Fitness History Kids & Family
  • Leisure Music News Religion & Spirituality Science
  • Society & Culture Sports Technology True Crime TV & Film
  • Live
  • How to Start a Podcast
  • How to Start a Live Podcast
  • How to Monetize a podcast
  • How to Promote Your Podcast
  • How to Use Group Recording
  • Log in
  • Start your podcast for free
  • Podcasting
    • Podcast Features
      • Podcast Hosting

        Start your podcast with all the features you need.

      • Podbean AI Podbean AI

        AI-Enhanced Audio Quality and Content Generation.

      • Blog to Podcast

        Repurpose your blog into an engaging podcast.

      • Video to Podcast

        Convert YouTube playlists to podcasts, videos to audios.

    • Monetization
      • Ads Marketplace

        Join Ads Marketplace to earn through podcast sponsorships.

      • PodAds

        Manage your ads with dynamic ad insertion capability.

      • Apple Podcasts Subscriptions Integration

        Monetize with Apple Podcasts Subscriptions via Podbean.

      • Live Streaming

        Earn rewards and recurring income from Fan Club membership.

    • Podbean App
      • Podcast Studio

        Easy-to-use audio recorder app.

      • Podcast App

        The best podcast player & podcast app.

  • Advertisers
  • Enterprise
  • Pricing
  • Resources
    • Help and Support
      • Help Center

        Get the answers and support you need.

      • Podbean Academy

        Resources and guides to launch, grow, and monetize podcast.

      • Podbean Blog

        Stay updated with the latest podcasting tips and trends.

      • What’s New

        Check out our newest and recently released features!

      • Podcasting Smarter

        Podcast interviews, best practices, and helpful tips.

    • Popular Topics
      • How to Start a Podcast

        The step-by-step guide to start your own podcast.

      • How to Start a Live Podcast

        Create the best live podcast and engage your audience.

      • How to Monetize a Podcast

        Tips on making the decision to monetize your podcast.

      • How to Promote Your Podcast

        The best ways to get more eyes and ears on your podcast.

      • Podcast Advertising 101

        Everything you need to know about podcast advertising.

      • Mobile Podcast Recording Guide

        The ultimate guide to recording a podcast on your phone.

      • How to Use Group Recording

        Steps to set up and use group recording in the Podbean app.

  • Discover
  • Log in
    Sign up free
Python Bytes

Python Bytes

Technology

#272 The tools episode

#272 The tools episode

2022-02-24
Download Right click and do "save link as"

Watch the live stream:

Watch on YouTube

About the show

Sponsor: Brought to you by FusionAuth - check them out at pythonbytes.fm/fusionauth

Special guest: Calvin Hendryx-Parker

Brian #1: Why your mock still doesn’t work

  • Ned Batchelder
  • Some back story: Why your mock doesn’t work
    • a quick tour of Python name assignment
      • The short version of Python Names and Values talk
    • importing
    • difference between from foo import bar and import foo w.r.t mocking
    • punchline: “Mock it where it’s used”
  • Now, Why your mock still doesn’t work talks about
    • using @patch decorator (also applies to @patch.object decorator)
    • and utilizing mock_thing1, mock_thing2 parameters to test
    • you can change the return value or an attribute or whatever. normal mock stuff.
    • But…. the punchline…. be careful about the order of patches.
  • It needs to be
@patch("foo.thing2") @patch("foo.thing1") def test_(mock_thing1, mock_thing2): ...
  • Further reading:
    • https://docs.python.org/3/library/unittest.mock.html#patch
    • https://docs.python.org/3/library/unittest.mock.html#patch-object

Michael #2: pls

  • via Chris May
  • Are you a developer who uses the terminal? (likely!)
  • ls/l are not super helpful. There are replacements and alternatives
  • But if you’re a dev, you might want the most relevant info for you, so enter pls
  • See images in Michael’s tweets [1, 2].
  • You must install nerdfonts and set your terminal’s font to them

Calvin #3: Kitty

  • Cross platform GPU accelerated terminal (written in Python
  • Extended with Kittens written in Python
  • Super fast rendering
  • Has a rich set of plugins available for things like searching the buffer with fzf

Brian #4: Futures and easy parallelisation

  • Jaime Buelta
  • Code example for quick scripts to perform slow tasks in parallel.
  • Uses concurrent.futures and ThreadPoolExecutor.
  • Starts with a small toy example, then goes on to a requests example to grab a bunch of pages in parallel.
    • The call to executor.submit() sets up the job.
      • This is done in a list comprehension, generating a list of futures.
    • The call to futures.result() on each future within the list is where the blocking happens. Since we want to wait for all results, it’s ok to block on the first, second, etc.
  • Nice small snippet for easy parallel work.
  • Example:
from concurrent.futures import ThreadPoolExecutor import time import requests from urllib.parse import urljoin NUM_WORKERS = 2 executor = ThreadPoolExecutor(NUM_WORKERS) def retrieve(root_url, path): url = urljoin(root_url, path) print(f'{time.time()} Retrieving {url}') result = requests.get(url) return result arguments = [('https://google.com/', 'search'), ('https://www.facebook.com/', 'login'), ('https://nyt.com/', 'international')] futures_array = [executor.submit(retrieve, *arg) for arg in arguments] result = [future.result() for future in futures_array] print(result)

Michael #5: pgMustard

  • So you have a crappy web app that is slow but don’t know why.
  • Is it an N+1 problem with an ORM?
  • Is it a lack of indexes?
  • If you’re using postgres, check out pgMustard: A simple yet powerful tool to help you speed up queries
  • This is a paid product but might be worthwhile if you live deeply in postgres.

Calvin #6: bpytop

  • Great way to see what is going on in your system/server
  • Shows nice graphs in the terminal for system performance such as CPU and Network traffic
  • Support themes and is fast and easy to install with pipx
  • Michael uses Glances which is fun too. Calvin used to be a heavy Glances user until he saw the light 🙂

Extras

Brian:

  • pytest book is officially no longer Beta, next is printing, expected paper copy ship date at March 22, although I’m hoping earlier.
    • For a limited time, to celebrate, 40% off the eBook
  • PyCamp Spain is April 15-18: a weekend that includes 4 days and 3 nights with full board (breakfast, lunch and dinner) in Girona, Spain

Calvin:

  • Python Web Conference 2022 ← bigger and better than ever!

Michael:

  • witch macOS switcher
  • list comprehensions vs. loops [[video](https://www.youtube.com/watch?v=uVQVn8z8kxo), [code](https://gist.github.com/mikeckennedy/2ddb5ad84d6e116e6d14b5c2eef4245a)]
  • syncify.run and nesting asyncio

Joke: Killer robots

view more

More Episodes

#238 A cloud-based file system for Python and a new GUI!
2021-06-15
#237 Separate your SQL and Python, asynchronously with aiosql
2021-06-09
#236 Fuzzy wuzzy wazzy fuzzy was faster
2021-06-02
#235 Flask 2.0 Articles and Reactions
2021-05-26
#234 The Astronomy-filled edition with Dr. Becky
2021-05-19
#233 RaaS: Readme as a Service
2021-05-12
#232 PyPI in a box and a revolutionary keyboard
2021-05-05
#231 Go Python, Go!
2021-04-28
#230 PyMars? Yes! FLoC? No!
2021-04-21
#229 Has one of your dependencies died?
2021-04-15
#228 Supreme Court decides API copyright battle
2021-04-07
#227 No more awaiting, async comes to SQLAlchemy
2021-03-31
#226 Teaching Python podcast on the podcast!
2021-03-25
#225 SELECT Pydantic FROM MongoDB
2021-03-17
#224 Join us on a Python adventure back to 1977
2021-03-10
#223 Beware: A ninja is shadowing Sebastian from FastAPI
2021-03-03
#222 Autocomplete with type annotations for AWS and boto3
2021-02-24
#221 Pattern matching and accepting change in Python with Brett Cannon
2021-02-19
#220 What, why, and where of friendly errors in Python
2021-02-11
#219 HTMX: Dynamic and live HTML without JavaScript
2021-02-03
  • ←
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • →
012345678910111213141516171819

Get this podcast on your
phone, FREE

Download Podbean app on App Store Download Podbean app on Google Play

Create your
podcast in
minutes

  • Full-featured podcast site
  • Unlimited storage and bandwidth
  • Comprehensive podcast stats
  • Distribute to Apple Podcasts, Spotify, and more
  • Make money with your podcast
Get started

It is Free

  • Podcast Services

    • Podcast Features
    • Pricing
    • Enterprise Solution
    • Private Podcast
    • The Podcast App
    • Live Stream
    • Audio Recorder
    • Remote Recording
    • Podbean AI
  •  
    • Create a Podcast
    • Video Podcast
    • Start Podcasting
    • Start Radio Talk Show
    • Education Podcast
    • Church Podcast
    • Nonprofit Podcast
    • Get Sermons Online
    • Free Audiobooks
  • MONETIZATION & MORE

    • Podcast Advertising
    • Dynamic Ads Insertion
    • Apple Podcasts Subscriptions
    • Switch to Podbean
    • YouTube to Podcast
    • Blog to Podcast
    • Submit Your Podcast
    • Podbean Plugins
    • Developers
  • KNOWLEDGE BASE

    • How to Start a Podcast
    • How to Start a Live Podcast
    • How to Monetize a Podcast
    • How to Promote Your Podcast
    • Mobile Podcast Recording Guide
    • How to Use Group Recording
    • Podcast Advertising 101
  • Support

    • Support Center
    • What’s New
    • Free Webinars
    • Podcast Events
    • Podbean Academy
    • Podbean Amplified Podcast
    • Badges
    • Resources
  • Podbean

    • About Us
    • Podbean Blog
    • Careers
    • Press and Media
    • Green Initiative
    • Affiliate Program
    • Contact Us
  • Privacy Policy
  • Cookie Policy
  • Terms of Use
  • Consent Preferences
  • Copyright © 2015-2025 Podbean.com