DeepDiff Tutorial: Comparing Numbers

This tutorial is written based on DeepDiff 4.0.6. One of the features of DeepDiff that comes very handy is comparying nested data structures that include numbers. There are times that we do care about the exact numbers and want it to be reported if anything slightly changed. from pprint import pprint from deepdiff import DeepDiff t1 = {"key": [1.2, 1.5]} t2 = {"key": [1.20, 1.50]} >>> pprint(DeepDiff(t1, t2)) {} Let’s say the numbers gets more precise:
Read more

You AutoComplete Me

Part 1: Into Auto Complete: Summary Back in 2018, I was given the task to improve our autocomplete experience. We already had an Autocomplete backend solution using Elasticsearch, but what we needed was something that was faster, more customizable which could handle complex queries such as red bmw x5 in napa 2019. This is the story of how I approached it, what I learnt, and the final product that it came to be, using a pure Python solution!
Read more

Magic Method, on the wall, who, now, is the __fairest__ one of all?

Update May 22: Here is the video of the talk: The Proposal This was my talk proposal for Pycon 2017 which got accepted. The proposal is slightly modified to match the final talk better. For example originally I was going to talk about writing a Redis Client too but I ended up removing that from the final talk. I will be giving this talk tomorrow on Saturday May 20th!
Read more

Subclassing dictionary in Python.

Take a look at this: >>> c={'something': 2} >>> c.__dict__ Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'dict' object has no attribute '__dict__' Now let’s subclass dict: >>> class B(dict): ... def pass ... >>> b=B(something=2) >>> b {'something': 2} >>> b.__dict__ {} So dictionary don’t have __dict__ but if you subclass them, then they have __dict__. Interesting, eh?

Harness the power of Python magic methods and lazy objects.

This is based on a talk I gave at SoCal Python meetup. The PDF of this talk is available here. All the code is run in Python 3.5 but it works with Python 2 too. Overview When it comes to performance, lazy loading can help a lot. I remember when I first started using Django and Django’s lazy queries were magic to me. In this article I will try to dimistify lazy objects in Python, mainly focusing on lazy loading aspect but not lazy writing.
Read more

RedisWorks, the Pythonic Redis Client.

As a person who loves dynamic typing, I have always been frustrated with Py-Redis. It is a great library, but it is too low level. It maps the actual Redis commands directly. I always wanted to just say the.path = "something" and have it magically saved into Redis. Then somewhere else say print(the.path) and get the value from Redis. As simple as that! And here it is: RedisWorks Install pip install redisworks
Read more

Amazon S3 made simple for Python apps.

From time to time I need to do some simple file/folder transfer/query from a Python app to a S3 bucket. There is a great Python library called Boto that offers a comprehensive low level interface to AWS. I consider it too low level for simple operations on S3. On the other hand there is a fantastic command line library called s3cmd written in Python but it is designed to be used from command line and not from Python apps.
Read more

Diff It To Digg It

The Talk Here is the actual talk! I gave a talk at Pycon 2016 about how DeepDiff does what it does. The proposal This is my Python talk proposal for 2016. It is about how my DeepDiff does what it does. I will be presenting this talk on June 1st at Pycon. Edit (June 2016): read more about how the presentation went at Pycon presentation after thoughts
Read more

Celery: Get Your Task Together

Why Distributed Task Queues? Offload long jobs to background processes example: video conversion Offload too many [small] jobs to background processes example: commenting system Keep track of jobs, monitor, auto-restart Schedule jobs Replace cron jobs. Cron jobs can run maximum once a minute. That is a limitation. And they don’t have the best interface. Message Queue vs. Task Queue Message Queue are the basic functionality of passing, holding, and delivering messages Example: Redis, RabbitMQ Tasks Queue manage work to be done and is considered a type of message queue Example: Celery Distributed Task Queus in Python
Read more