๐Ÿ 8 backend repos used by the top 1% of python devs ๐Ÿ†

Bap - Jan 4 - - Dev Community

Hi there ๐Ÿ‘‹

Today, let's look into 8 Python repos that the top 1% of developers use (and those you have likely never heard of).

Ready?

Image description


How do we find the repos used by the top 1% of devs? ๐Ÿ”Ž

At Quira, we rank developers based on their DevRank.

In simple terms, DevRank uses Googleโ€™s PageRank algorithm to measure how important a developer is in open source based on their contributions to open source repos.

We thus look at the repos that the top 1% have starred. We then calculate the likelihood that the top 1% of developers will star a repo compared to the likelihood that the bottom 50% wonโ€™t.

Lastly, after a bit of hand-picking, we found our 8 final repos. ๐Ÿ“Š๐Ÿ‘‡

Image description

Note: We use stars as a rough measure of usage. Whilst this method isn't perfect, we recognise it offers insight into the tools favoured by top developers.


These repos will be particularly useful when building projects with a robust backend.

If you are interested in working on building small apps, and you enjoy the applied AI side, we recommend you check out Creator Quests, an open-source challenge that rewards developers for creating cool GenerativeAI apps with ChatGPT, Claude, Gemini and more. ๐Ÿ™ƒ ๐Ÿ’ฐ

The latest Creator Quest challenges you to build developer tools using Generative AI. To participate, simply sign up to Quira and head to Quests.

The current prize pool is $2048, and it will increase as more participants join! Click on the image below and give it a try! โฌ‡๏ธ

Image description

Enough about this; let's dive into our findings and how you can benefit from them! ๐Ÿ‘‡


๐Ÿ•ธ๏ธ aio-libs/yarl

The URL library you have never heard of

Why should you care? Yarl is designed for easy and efficient URL management and analysis in Python. It handles encoding and decoding, allowing you to create, analyze and modify URLs in a simple way.

Set up: pip install yarl

Example use case:

from yarl import URL
url = URL('https://www.python.org/~guido?arg=1#frag')

# All url parts: scheme, user, password, host, port, path, query and fragment are accessible by properties:

>>> url.scheme
'https'
>>>  url.host
'www.python.org'
>>> url.path
'/~guido'
>>> url.query_string
'arg=1'
>>> url.query
<MultiDictProxy('arg': '1')>
>>> url.fragment
'frag'

Enter fullscreen mode Exit fullscreen mode

https://github.com/aio-libs/yarl


๐Ÿ—ƒ๏ธ Suor/django-cacheops

Your new caching best friend

Why should you care? Django-cacheops is a Django application that uses Redis to provide advanced caching capabilities, including automatic query caching and event-based automatic caching. It can speed up Django applications by reducing data load and has features like function and view caching.

Set up: pip install django-cacheops

Example use case:


# Function caching
from cacheops import cached_as

@cached_as(Article, timeout=120)
def article_stats():
    return {
        'tags': list(Article.objects.values('tag').annotate(Count('id')))
        'categories': list(Article.objects.values('category').annotate(Count('id')))
    }

Enter fullscreen mode Exit fullscreen mode

https://github.com/Suor/django-cacheops


๐Ÿ‘€ samuelcolvin/watchfiles

File watching and code reload in Python

Why should you care? Watchfiles are essential because they automatically reset your code every time you make a change. This means you won't have to restart your server every time you update your content. It is also very easy to install and work on different projects, making your development process smoother and more efficient.

Set up: pip install watchfiles
Example use case: watch usage


from watchfiles import watch

for changes in watch('./path/to/dir'):
    print(changes)

Enter fullscreen mode Exit fullscreen mode

https://github.com/samuelcolvin/watchfiles


๐Ÿงช FactoryBoy/factory_boy

Test your Python apps with fake but realistic data

Why should you care? Factory_boy is a tool that helps you quickly create fake but realistic data to test your Python application. It's like having an assistant who can automatically create any test case you need. This makes it easier to check whether your application works well in different situations.

Set up: pip install factory_boy

Example use case:


class FooTests(unittest.TestCase):

    def test_with_factory_boy(self):
        # We need a 200โ‚ฌ, paid order, shipping to australia, for a VIP customer
        order = OrderFactory(
            amount=200,
            status='PAID',
            customer__is_vip=True,
            address__country='AU',
        )
        # Run the tests here

    def test_without_factory_boy(self):
        address = Address(
            street="42 fubar street",
            zipcode="42Z42",
            city="Sydney",
            country="AU",
        )
        customer = Customer(
            first_name="John",
            last_name="Doe",
            phone="+1234",
            email="john.doe@example.org",
            active=True,
            is_vip=True,
            address=address,
        )
        # etc.


Enter fullscreen mode Exit fullscreen mode

https://github.com/FactoryBoy/factory_boy


๐Ÿ’ฝ hugapi/hug

Developing APIs as simple as possible.

Why should you care? Hug is a framework that easily creates APIs in Python and is designed to protect your code as much as possible. It is made for fast and self-documenting code support, making your development more intuitive.

Set up: pip3 install hug --upgrade
Example use case:


# Build an example API with a simple endpoint in just a few lines.

# filename: happy_birthday.py
"""A basic (single function) API written using hug"""
import hug


@hug.get('/happy_birthday')
def happy_birthday(name, age:hug.types.number=1):
 ย  ย """Says happy birthday to a user"""
    return "Happy {age} Birthday {name}!".format(**locals())


Enter fullscreen mode Exit fullscreen mode

https://github.com/hugapi/hug


๐Ÿ“‘ joeyespo/grip

Preview GitHub README.md files locally before committing them.

Why should you care? Grip allows you to use GitHub's own Markdown API to create local Markdown archives (like a README) before pushing to GitHub. This is great for getting your files directly to GitHub without the trial and error of pushing and reviewing.

Set up: pip install grip or for brew users brew install grip

Example use case:

# To render the readme of a repository

$ cd myrepo
$ grip
 * Running on http://localhost:6419/

Enter fullscreen mode Exit fullscreen mode

https://github.com/joeyespo/grip


๐Ÿ”Ž joerick/pyinstrument

Find why and where your code is slow!

Why should you care? Pyinstrument is a performance analysis tool that helps you identify areas of your code that are slowing down your application. You can run your script as usual and get detailed information about where it spends the most time, helping you tune your code to be more efficient.

Set up: pip install pyinstrument
Example use case:


# Instead of writing python script.py, type pyinstrument script.py. 
# Your script will run as normal, and at the end (or when you press ^C)
# Pyinstrument will output a colored summary showing where most of the time was spent.


# Pyinstrument also has a Python API. Just surround your code with Pyinstrument, like this:

from pyinstrument import Profiler

profiler = Profiler()
profiler.start()

# code you want to profile

profiler
.stop()

profiler.print()
Enter fullscreen mode Exit fullscreen mode

https://github.com/joerick/pyinstrument


โœ๏ธ marshmallow-code/apispec

A pluggable API specification generator

Why should you care? Apispec is a tool for creating API documentation with specific support for the OpenAPI specification. This means it automatically creates a clear, structured document for your API endpoint.

Set up: pip install -U apispec

Example use case:

from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
from apispec_webframeworks.flask import FlaskPlugin
from flask import Flask
from marshmallow import Schema, fields


# Create an APISpec
spec = APISpec(
    title="Swagger Petstore",
    version="1.0.0",
    openapi_version="3.0.2",
    plugins=[FlaskPlugin(), MarshmallowPlugin()],
)

# Optional marshmallow support
class CategorySchema(Schema):
    id = fields.Int()
    name = fields.Str(required=True)


class PetSchema(Schema):
    category = fields.List(fields.Nested(CategorySchema))
    name = fields.Str()


# Optional security scheme support
api_key_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"}
spec.components.security_scheme("ApiKeyAuth", api_key_scheme)


# Optional Flask support
app = Flask(__name__)


@app.route("/random")
def random_pet():
    """A cute furry animal endpoint.
    ---
    get:
      description: Get a random pet
      security:
        - ApiKeyAuth: []
      responses:
        200:
          content:
            application/json:
              schema: PetSchema
    """
    pet = get_random_pet()
    return PetSchema().dump(pet)


# Register the path and the entities within it
with app.test_request_context():
    spec.path(view=random_pet)

Enter fullscreen mode Exit fullscreen mode

https://github.com/marshmallow-code/apispec


I hope our discoveries are valuable and will help you build a robust backend toolkit! โš’๏ธ

If you want to leverage these tools today to earn rewards, we have just launched a challenge to build a developer tool using Generative AI.

If that's of interest, log into Quira and discover Quests! ๐Ÿ’ฐ

It's time to code, have fun and bag some awesome rewards. ๐Ÿค˜

Image description

Lastly, please consider supporting these projects by starring them. โญ๏ธ

PS: We are not affiliated with them. We just think that great projects deserve great recognition.

See you next week,

Your Dev.to buddy ๐Ÿ’š

Bap


If you want to join the self-proclaimed "coolest" server in open source ๐Ÿ˜, you should join our discord server. We are here to help you on your journey in open source. ๐Ÿซถ

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .