DEV Community

Cover image for Ostrich algorithm python package
Sour durian
Sour durian

Posted on

Ostrich algorithm python package

Was taking a break from the serious programming stuff, so I created this python package.

Here goes!

The Ostrich Algorithm is a term in programming where developers deliberately ignore certain problems in their code (like an ostrich "burying its head in the sand"). While it sounds like a joke, it's actually a legitimate strategy when:
The problem is super unlikely to occur (or at least we hope so)
Fixing it would cost more than ignoring it
You're dealing with legacy code that works (don't touch it ever!)
Your deadline was yesterday
So ... I created a package that does just that! Except that mine is more of a joke. To use it,

from ostrich import ostrich, Priority

@ostrich(Priority.HIGH, "PERF-123", lines={
    8: "This query makes the DB cry",})
def calculate_user_metrics():
    query = "SELECT * FROM users WHERE..."  
    for metric in all_metrics:             
        results.append(calculate_metric(user, metric))
    return results

`# The output will look like:
# [OSTRICH HIGH][PERF-123] watching from line 3
# Marked lines in this function:
# Line 15 -> This query makes the DB cry
#     query = "SELECT * FROM users WHERE..."`
Enter fullscreen mode Exit fullscreen mode

It will watch from whichever line has the ostrich decorator. And it will highlight that part so that you can just ignore it (or prioritise it).

Any comments/hate/feedback/criticism welcomed.

Link to the github: [(https://github.com/duriantaco/ostrich)]

Image of Stellar post

From Hackathon to Funded - Stellar Dev Diaries Ep. 1 πŸŽ₯

Ever wondered what it takes to go from idea to funding? In episode 1 of the Stellar Dev Diaries, we hear how the Freelii team did just that. Check it out and follow along to see the rest of their dev journey!

Watch the video

Top comments (0)

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup πŸš€

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay