This week we welcome Adam Johnson (@adamchainz) as our PyDev of the Week! Adam is a member of the Django project Technical Board. He also co-organizes the London Django Meetup. Adam is the author of Speed Up Your Django Tests. You can see what else is going on with Adam over on his website.
Let’s spend a few moments getting to know Adam better!
Can you tell us a little about yourself (hobbies, education, etc):
Hi, I’m Adam Johnson. I am British and live in London with my Portuguese partner. She often takes me to Lisbon, so at least I get some sun there.
I have been programming since I was 8 years old when my Dad introduced me to QuickBasic on the first family computer. My brother and I wrote our own computer games rather than buy any. This eventually led to us releasing game creator software together when we were teenagers.
I currently work as a contractor through my company Adam’s Web Services Ltd, doing Django/Python consulting.
I love to cycle, read, and drink tea (mostly green!).
Why did you start using Python?
Before and during university, I used PHP to build websites, without any framework. I thought this was great, but in retrospect, everything was a bit cowboy – no database migrations, tests, and manual deployments through FTP!
My first job after uni was with a startup, Memrise, where I moved to Python and Django. I’ve loved it ever since. I found Python easier to understand than PHP, and less typing. Django gave me plenty of tools that helped me build web pages faster. It was a great learning experience because I joined as the site was at an inflection point, scaling up to a million users.
What other programming languages do you know and which is your favorite?
I’ve tried a bunch of other languages, especially through university where the first course was in Haskell! And I still try to experiment with one new language each year to expose myself to new ideas.
The most recent such language was Rust, for which I followed the official book online. I think it has great foundations and there are many great things coming from the Rust community. I’m excited to see more systems-level tools moving to it to prevent memory unsafety. I hope I can use it directly on a project in the future.
Day-to-day at the moment I use nearly exclusively Python, JavaScript and C. JavaScript I use where necessary to build particular features, but I try to avoid. The C code I’ve written recently has been for Python extensions, notably time-machine, a datetime mocking library that I released last year.
What projects are you working on now?
I have several client projects that I rotate between. Mostly my role there is to advise on Django/Python best practices and help with infrastructure.
My work often leads me to create or update open source projects, so I can be found making or maintaining some libraries on PyPI. I’ve created extensions for Django, flake8, and pytest.
I am also working to update my book, Speed Up Your Django Tests, for recent changes to Django. Writing the book last year also spurred me to make many changes to improve the Python testing ecosystem (such as time-machine), and some of these need to make their way back into the book now!
Finally, I have started working on a database monitoring tool, DB Buddy. I hope it will help users employ some of the best practices for PostgreSQL, especially things that might be hidden when using an ORM like Django’s. There’s not much to see right now but it’s slowly making progress.
Which Python libraries are your favorite (core or 3rd party)?
Naturally, I like Django, which goes from strength to strength. Each new version brings some great improvements, and the community is just fantastic. I really miss physical meetups/conferences with fellow Django developers.
I also really enjoy using pytest. It’s a great testing framework and I try to move all client projects onto it.
For web development I have recently been enjoying htmx. This extends HTML with abilities to rerender parts of the page on the server, allowing you to avoid writing JavaScript. So it’s not a Python library, but it does let you use more Python in your web apps. I built a small library, django-htmx, to help Django applications use htmx.
Why Django versus another Python web framework?
Great question! A couple of years ago, I wrote a blog post comparing Django to Flask, through the aspect of how well they work inside a single file. When looking for a minimal app in a single file, most developers think of Flask or similar, but Django can work in very little code too.
My post looked at the differences between the two frameworks’ implementations of the same apps, and what the code implied about each framework. It reveals some of the differences and also my preferences.
To summarize, I prefer Django because it has a slightly more structured approach, more built-in features, a bigger ecosystem, and more stable maintenance thanks to its donations.
I’ve had a look at most other Python web frameworks since I was helping maintain an APM (Application Performance Monitoring) package until recently. This led me to build integrations with nearly a dozen frameworks. There are some great ideas out there and some great API-specific frameworks, but I am sticking with Django helping copy the best ideas I see out there.
How did your book, “Speed Up Your Django Tests”, come about?
Essentially, I got carried away blogging. One day I started to write a listicle on the top ways to speed up your tests, and the methods just kept coming. After 24 hours I had a 4000 word *outline* and I realized I needed more space to cover everything. So I decided to forge ahead and put the ideas into a book.
I was lucky enough to have done a ton of work previously optimizing test suites, so I had most of the information I needed buried somewhere in my brain. It’s been good to get it out of there and to see it helping others.
Is there anything else you’d like to say?
May your tests run fast and green.
Thanks for doing the interview, Adam!
Pingback: ICYMI Python on Microcontrollers Newsletter: Happy 8th Birthday MicroPython, sponsorship and more! #Python #Adafruit #CircuitPython #ICYMI @micropython @ThePSF « Adafruit Industries – Makers, hackers, artists, designers and engineers!