Sharing a mutable reference with Python

Background As part of my ongoing project to reimplement Django’s templating language in Rust, I have been adding support for custom template tags. Simple tags The simplest custom tag will look something like: # time_tags.py from datetime import datetime from django import template register = template.Library() @register.simple_tag def time(format_string): now = datetime.now() return now.strftime(format_string) # time_tags.py from datetime import datetime from django import template register = template.Library() @register.simple_tag def current_time(format_string): return datetime.now().strftime(format_string) ...

September 2, 2025

How we reduced the memory usage of our Rust extension by 4x

This post was originally published on the Kolo Blog and has been republished here with thanks to Wil Klopp. What is Kolo? Kolo is a dynamic code analysis tool for Python. We use Python’s sys.setprofile to introspect Python’s call stack and local variables. For performance reasons, Kolo is partially implemented in Rust using the excellent PyO3 crate. The bug report Recently, we received a report of Kolo running out of memory when analysing an unusually large Django view. To get an idea of what was causing it, I created a very simple python script that would generate a lot of python frames: ...

October 9, 2023