‹ Back to Blog

Python

How a Singleton Pattern Broke Our Django Logging

When wrapping resources in Singleton objects, understanding the lifecycle behavior of both the underlying resource and the calling code is key. Django loves to close logging handlers frequently during its boot cycle. Debugging log handlers is its own special kind of fun; read on for the schadenfreude.

Adding FastMCP support to the Scout Python Agent

Scout Senior Developer Quinn walks us through adding FastMCP instrumentation to our Python agent. The Scout MCP server enables Scout users to query their Scout agent about application performance so that the agent can make decisions and fix issues based on that data.

Django and the N+1 Queries Problem

The N+1 Queries Problem is a perennial database performance issue. It affects many ORM’s and custom SQL code, and Django’s ORM is not immune either. In this post, we’ll examine what the N+1 Queries Problem looks like in Django, some tools for fixing it, and most importantly some tools for ...

A Guide to Python Lambda Functions

In Python, Lambda functions are rare compared to “normal” functions, and occasionally misunderstood or overused. In this article we’ll cover what Lambda functions are, how to use them, and how they compare with normal functions and other alternatives. We’ll also touch on the history of lambda functions, such as where ...

The Most Popular Python Web Frameworks in 2021

Web frameworks are powerful tools. They abstract the common aspects of building web sites and APIs and allow us to build richer, more stable applications with less effort. A broad range of web frameworks is available to us in Python. Some are proven favorites with large ecosystems and communities. Others ...

Better Python Decorators with Wrapt

A Python decorator wraps a target function with another wrapper function. This wrapper function can add any behavior you might want. For example, it can track execution times, redefine how the wrapped function runs, or modify return values. As a concrete example, the standard library’s functools.lru_cache() decorator wraps a target ...

Go Fast: Getting Started with Sanic for Python

Go Fast: Getting Started with Sanic for Python Tired of waiting for sluggish HTTP requests to complete before your backend code can proceed with other things? Sanic is an asynchronous web framework in Python, that is built to be fast. In a world where Flask and Django are the most ...

Migrating from Python 2 to 3: Automated Tools and Strategies

This article is a continuation of Part I (A comprehensive guide to migrating from Python 2(Legacy Python) to Python 3) which details the changes, improvements in Python 3 and why they are important. This rest of the article details automated tools, strategies and role of testing in the migration from ...

Python Language vs. Ruby Language

In this blog post, we'll be going through two server-side scripting languages; Python and Ruby with focus on comparing the performance and other factors that might help you in deciding which language to pick over the other for your web application.

Memory Management in Python

Memory management in python: Yes, you heard it right “memory management in python”. You must be thinking: why do I need to manage the memory in any high-level language like python?

Monitoring Django apps on Heroku

I don't know of an easier way to deploy a Django app than letting Heroku do the work. That said, how do you stay on top of your app's performance, errors, and stability post-launch? Running an app on Heroku is a blissful experience, but it presents some monitoring challenges that ...

Why put Rust in our Python Monitoring agent?

Prior to adding Python performance monitoring , we'd written monitoring agents for Ruby and Elixir . Our Ruby and Elixir agents had duplicated much of their code between them, and we didn't want to add a third copy of the agent-plumbing code. The overlapping code included things like JSON payload ...

A tour of Python monitoring tools

Prior to releasing our Python Performance Monitoring agent, we took a look at the Python ecosystem to see how Scout can compliment the existing landscape. What follows is a summary of our internal report. The Python ecosystem has a wealth of monitoring tools. That said, making sense of each tool's ...

OpenTracing Tutorial: Using Flask Python Requests

A transaction trace is a GPS system for web performance: it paints a rich picture of the flow of a web request through your code. So, why doesn't everybody trace? I believe there are two reasons: Complex instrumentation : Adding in-app tracing instrumentation is more involved than calling logger.info() for ...