Python Icon

Python

Python is a dynamically typed programming language.
308 Stories
All Topics

Kafka github.com

FastKafka is a Python library for building Kafka-based services

Dave Runje:

We were searching for something like FastAPI for Kafka-based service we were developing, but couldn’t find anything similar. So we shamelessly made one by reusing beloved paradigms from FastAPI and we shamelessly named it FastKafka.

The point was to set the expectations right - you get pretty much what you would expect: function decorators for consumers and producers with type hints specifying Pydantic classes for JSON encoding/decoding, automatic message routing to Kafka brokers and documentation generation.

Apple github.com

Transformer architecture optimized for Apple Silicon

Use ane_transformers as a reference PyTorch implementation if you are considering deploying your Transformer models on Apple devices with an A14 or newer and M1 or newer chip to achieve up to 10 times faster and 14 times lower peak memory consumption compared to baseline implementations.

We were just discussing Apple’s next AI move on yesterday’s JS Party live (ships to the feed next Friday). They’ve been the quietest tech giant since the GenAI movement kicked in to high gear. My guess: they’ll have a LOT to say at this June’s WWDC…

Tyler Cipriani tylercipriani.com

Monitoring my weather at home 🌩️

Tyler Cipriani:

Despite their best efforts, all weather apps will eventually lie.

Weather is often hyper-local…

So, in 2013, I set up a Davis Vantage Vue integrated sensor suite (ISS) and mounted it on a pole attached to my garage.

The heart of his system is WeeWX, a free and open source weather station software written in Python. Ten years later, he’s learned some things, but he’s still using his homegrown weather monitoring.

Python github.com

ImaginAIry imagines & edits images from text inputs

This is a Pythonic wrapper around stable diffusion with image editing by InstructPix2Pix. The four images featured below (top) are generated by the following command:

imagine "a scenic landscape" "a photo of a dog" "photo of a fruit bowl" "portrait photo of a freckled woman"

Then they are edited (bottom) with the following commands:

>> aimg edit scenic_landscape.jpg "make it winter" --prompt-strength 20
>> aimg edit dog.jpg "make the dog red" --prompt-strength 5
>> aimg edit bowl_of_fruit.jpg "replace the fruit with strawberries"
>> aimg edit freckled_woman.jpg "make her a cyborg" --prompt-strength 13
ImaginAIry imagines & edits images from text inputs

Python github.com

A library for building apps with LLMs through composability

Large language models (LLMs) are emerging as a transformative technology, enabling developers to build applications that they previously could not. But using these LLMs in isolation is often not enough to create a truly powerful app - the real power comes when you can combine them with other sources of computation or knowledge.

This library is aimed at assisting in the development of those types of applications.

LangChain is designed to help with prompts, chains (sequences of calls), data augmented generation, agents, memory & evaluation tasks.

Martin Heinz martinheinz.dev

Python magic methods you haven’t heard about

Python’s magic methods - also known as dunder (double underscore) methods - can be used to implement a lot of cool things. Most of the time we use them for simple stuff, such as constructors (__init__), string representation (__str__, __repr__) or arithmetic operators (__add__/__mul__). There are however many more magic methods which you probably haven’t heard about and in this article we will explore all of them (even the hidden and undocumented).

Bill Prin billprin.com

Why I ditched Django for NextJS

If you’re feeling the FOMO of JavaScript or you’re writing “spaghetti code” just to do something a NextJS component would do out of the box, then read this post from Bill Prin on why he moved from Django to NextJS.

The summary is that using a language like Python or Ruby for a significant web project has increasingly gotten less reasonable over time to the point where now, in 2022, it’s getting hard to justify. By not keeping your web stack in pure Javascript, you are making your life unnecessarily difficult (as usual, we’ll include languages like TypeScript as part of the JavaScript ecosystem). You will almost certainly invest a bunch of time-solving problems that would be automatically solved for you if you just stuck with JavaScript.

I will provide specific examples of solving problems using Django that would have been trivially solved in NextJS.

He goes on to share two reasons why you should use Python or Ruby for web projects in 2022.

You’re working on an existing project that hasn’t been migrated yet or is not worth migrating.
You are already a master of a Python or Ruby web stack, and you need to implement a new project as soon as possible, and you don’t have time to learn a better stack.

Changelog Interviews Changelog Interviews #511

The terminal as a platform

This week we’re talking with Will McGugan about using the terminal to not just build software, but also to deliver software. Will is a few months into his journey of building Textualize, a company he started around his open source projects Textual and Rich. When combined Textual and Rich give you a Python framework to build beautiful full-featured TUIs for the Terminal. We talk with Will about his big idea of the terminal as a platform, how he got here from first principles, what it takes to build Textual apps and whether or not they can replace not so good web admins, building, launching, and distributing Textual apps, why Python was his choiice of language, the big picture and business model behind Textualize, and why he’s building this as open source and in public.

Martin Heinz martinheinz.dev

Python CLI tricks that don't require any code whatsoever

Out-of-the-box, the Python standard library ships with many great libraries, some of which provide CLIs, allowing us to do many cool things directly from terminal without needing to even open a .py file.

This includes things like starting a webserver, opening a browser, parsing JSON files, benchmarking programs and many more, all of which we will explore in this article.

Python github.com

A tool for refurbishing and modernizing Python codebases

Point Refurb at your Python code to see how bad good it is. Here’s the author’s motivation:

I love doing code reviews: I like taking something and making it better, faster, more elegant, and so on. Lots of static analysis tools already exist, but none of them seem to be focused on making code more elegant, more readable, or more modern. That is where Refurb comes in.

Python github.com

A statement-based scheduling framework for Python

Unlike the alternatives, Rocketry’s scheduler is statement-based. Rocketry natively supports the same scheduling strategies as the other options, including cron and task pipelining, but it can also be arbitrarily extended using custom scheduling statements.

That’s pretty useful! I used to struggle to shove conditionals in to my cron jobs. Example time:

from rocketry.conds import daily, time_of_week
from pathlib import Path

@app.cond()
def file_exists(file):
    return Path(file).exists()

@app.task(daily.after("08:00") & file_exists("myfile.csv"))
def do_work():
    ...

Python pyscript.net

Create rich Python apps in the browser with HTML

PyScript is a Pythonic alternative to Scratch, JSFiddle, and other “easy to use” programming frameworks, with the goal of making the web a friendly, hackable place where anyone can author interesting and interactive applications.

Lots of code examples of various apps (clock, repl, todos, etc) here. I love the why behind this effort:

As an industry, we have focussed on making the impossible possible, rather than focussing on making the possible accessible to all.

They want to bring programming to the 99%. Somebody’s gotta do it…

Martin Heinz martinheinz.dev

Here's why you should be using Python's walrus operator

The assignment operator - or walrus operator as we all know it - is a feature that’s been in Python for a while now (since 3.8), yet it’s still somewhat controversial and many people have unfounded hate for it.

In this article I will try to convince you that the walrus operator really is a good addition to the language and that if you use it properly, then it can help you make your code more concise and readable.

Player art
  0:00 / 0:00