Python Mutable Defaults or the Second Thing I Hate Most About Python


Summary

  • If you’re working with Python @dataclass or Pydantic models you’re usually safe. @dataclass raises an excpetion when you mutate a field with defaults, and Pydantic models create deep copies of default values so never encounter that.

  • Don’t use default values for your annotated class attributes unless you explicitly state they are a ClassVar so you know what you’re doing.

I have also created a demo Flake8 plugin that checks your Python code against this. I hadn’t created a linter before so it was fun creating a small one and learning about it. You can check it in this repository flake8-explicitclassvar.

Read more ⟶

Ruby Thread Pooling


I have been always, naively, restrain myself from using multi-threading in Ruby because, as you know Ruby doesn’t have real threads until I read these awesome article by Nate Berkopec.

I was working on a web crawler, and aside from the huge (and expected) performance boost I implemented a thread pooling function that made my job easier not just for this particular usage but for almost every multi threading application, and I think it might helpful to share.

Read more ⟶

Exploring Ceph in a Multi Node Setup


Introduction

Caph is the future of data storage whether it was objects, blocks or a file system. It provides a great alternative to self-hosted solutions such as GlusterFS in the realm of file systems and to managed services such as AWS S3 as an object storage where it makes more sense to host your own data because you have to store it on private cloud or simply to reduce costs as S3 costs sometimes grow to be pretty insane.

Read more ⟶