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

#311 Catching Memory Leaks with ... pytest?

#311 Catching Memory Leaks with ... pytest?

2022-11-24
Download Right click and do "save link as"
Watch on YouTube

About the show

Python Bytes 311

Sponsored by Microsoft for Startups Founders Hub.

Connect with the hosts

  • Michael: @mkennedy@fosstodon.org
  • Brian: @brianokken@fosstodon.org
  • Special guest: Murilo Cunha

Michael #1: Latexify

  • We are used to turning beautiful math into programming symbols.
  • For example: amitness.com/2019/08/math-for-programmers/#sigma
  • Take this code: def do_math(a, b, c): return (-b + math.sqrt(b ** 2 - 4 * a * c)) / (2 * a)
  • Add @latexify.function decorator
  • display do_math in a notebook
  • Get this latex: \mathrm{do_math}(a, b, c) = \frac{-b + \sqrt{b^{{2}} - {4} a c}}{{2} a}
  • Which renders as

  • I could only get it to install with: pip install git+https://github.com/google/latexify_py

Brian #2: prefixed

  • From Avram Lubkin
  • “Prefixed provides an alternative implementation of the built-in float which supports formatted output with SI (decimal) and IEC (binary) prefixes.”

    >>> from prefixed import Float >>> f'{Float(3250):.2h}' '3.25k' >>> '{:.2h}s'.format(Float(.00001534)) '15.34μs' >>> '{:.2k}B'.format(Float(42467328)) '40.50MiB' >>> f'{Float(2048):.2m}B' '2.00KB'
  • Because prefixed.Float inherits from the built-in float, it behaves exactly the same in most cases.

  • When a math operation is performed with another real number type (float, int), the result will be a prefixed.Float instance.
  • also interesting
    • First new SI prefixes for over 30 years
    • new prefixes also show up here
  • -

Murilo #3: dbt

  • Open source tool
  • CLI tool
  • Built with Python 🐍
  • Applies “best practices” to SQL projects
  • Combines git + .sql files + jinja
  • Support many data platforms
  • Let’s you
    • Template SQL queries
      • Including loops
    • Execute DAGs
    • Data validation
    • Easily build docs (data lineage, visualize DAGs, etc.)
  • Now you can also run Python models
    • Useful if there’s a convenient python function for your data transformation or some more complex logic (i.e.:fuzzy string matching, machine learning models, etc.)
    • Available for Snowflake, Databricks, BigQuery
    • dbt’s coalesce’s announcement https://www.youtube.com/watch?v=rVprdyxcGUo

Michael #4: Memray pytest plugin

  • pytest-memray is the pytest plugin for, well, memray. :)
  • You can ensure that not too much memory is used with @pytest``**.**``mark``**.**``limit_memory``**(**``"24 MB"``**)**
  • And you get an allocation report with pytest --memray file.py
  • But coming soon, we’ll have memory leak checking too. @pytest.mark.check_leaks() def test_foobar(): # Do some stuff and ensure # it does not leak memory pass

Brian #5: Stealing Open Source code from Textual

  • Will McGugan
  • Will reminds us of one of the great benefits of open source code, stealing code
    • (when allowed by the license, of course)
  • Goes as far as to point out some bits of textual that you might want to lift
    • looping with indication of when you’ve hit the first or last item
    • a LRUCache with more flexibility than lru_cache
    • a Color class with conversions for css, hex, monochrome, hsl
    • 2d geometry

Murilo #6: Shed

  • Superset of black
  • "shed is the maximally opinionated autoformatting tool. It's all about convention over configuration, and designed to be a single opinionated tool that fully canonicalises my code - formatting, imports, updates, and every other fix I can possibly automate.”
  • Also format code snippets in docstrings, markdown, restructured text
  • No configuration options
  • pre-commit hooks available
  • Bundles together:
    • black
    • isort
    • autoflake
    • pyupgrade
    • blacken-docs

Extras

Brian:

  • pytest-check (version 1.1.3) changes now live
    • New README, hopefully makes it clear how to use.
    • Use check from
      • from pytest_check import check
      • or from the check fixture: def test_foo(check): …
    • Either form returns the same object.
    • From that check object, you can
      • use helper functions like check.equal(a, b), etc.
      • use it as a context manager, with check: assert a == b
      • even grab the raises context manager: with check.raises(Exception): …
    • Intended to be backwards compatible
      • although some old use cases might be deprecated/removed in the future.

Michael:

  • New YouTube Video: Best Native App for Mastodon is ...
  • Nearly 50% of macOS malware comes from one app — do you have it on your MacBook?
  • PyCascades CfP
  • A fresh take on blogging (for Michael): mkennedy.codes
    • Based on Hugo - which is so good.
    • Hosted on netlify.com

Murilo:

  • mastodon.py - a Python wrapper around Mastodon’s API
  • Nice notebook diffs in Github PRs 🚀
  • flake8 is not on Gitlab anymore
  • Who’s gonna win the world cup?
  • lancer

Joke:

  • Messing with the algorithm
  • Let’s start this one with some history
  • Recusion joke
view more

More Episodes

#359 gil--;
2023-11-02
#358 Collecting Shells
2023-10-24
#357 Python 3.7 EOLed, We Hadn't Noticed
2023-10-17
#356 Ripping from PyPI
2023-10-10
#355 Python 3.12 is Out!
2023-10-03
#354 Python 3.12 is Coming!
2023-09-26
#353 Hatching Another Episode
2023-09-19
#352 Helicopter Time Comes to Python
2023-09-12
#351 A Python Empire (or MPIRE?)
2023-09-06
#350 You've Got The Stamina For This Episode
2023-08-29
#349 Djangonauts: Ready for Takeoff!
2023-08-22
#348 JavaScript in Your Python
2023-08-15
#347 The One About Context Mangers
2023-08-08
#346 Have you lost your GIL?
2023-08-02
#345 Some Big Time Releases
2023-07-26
#344 AMA: Ask Us Anything
2023-07-18
#343 So Much Pydantic!
2023-07-11
#342 Don't Believe Those Old Blogging Myths
2023-06-26
#341 Shhh - For Secrets and Shells
2023-06-20
#340 Snorkel not included
2023-06-13
  • ←
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • →
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