Chat made me create a Reactive Python Library

preview_player
Показать описание
You'll also get 20% off an annual premium subscription.

———————————————————————————————
———————————————————————————————

I made my own reactive programming library (in Python). It's awesome.

In this video, I show how I created a useful reactive programming toolkit by leveraging the Observer design pattern, decorators, and operator overloading/magic methods.

In particular, we talk about Signals and Computed objects, which provide reactive values and functions. These objects are containers for values that can change, and will automatically notify any object observing them whenever their value changes. This creates a dynamic graph of computation that's particularly useful for UI and animation applications.

On top of that, you'll receive a surprise type hinting lesson on Generics and TypeVars.

Chapters
---------------
0:00 Intro
0:33 What is reactive programming?
1:19 How do we make objects reactive?
2:53 The Observer Design Pattern
4:13 This isn't that cool yet...
8:03 Draw the rest of the owl...
9:21 Prove it, buck-o
12:15 How do you type hint this?
16:35 How do you know it mostly works?

Credits
------------
Thanks to Siara M. for creating the animations in Section 3!

Software mentioned
---------------------------------

Disclosure
-----------------
This video was sponsored by Brilliant.

#python #reactive-programming
Рекомендации по теме
Комментарии
Автор


You’ll also get 20% off an annual premium subscription.

dougmercer
Автор

Oh snap. More awesome information that I am too busy to learn.

Reegx
Автор

This is incredibly well written - I read through your src code and am super impressed! I don't have much use for it at the moment but I will definitely consider it in the future! Would be interested to see more of how reactive_method could be used to do variable function declarations and calls, and how shared use of a Signal could be used for passing messages between threaded apps.

bradentoone
Автор

You can create type variables as classes in 3.13, with attributes to control covariance, defaults etc.
Maybe it can be used to generate types dynamically?

Having tried that myself, working on something so meta is very frustrating because you don't produce much in the end, and Python's typing is often the limit. Great for learning though!

remiheneault
Автор

This video is crazy good. Also nice sweater :)

noahgeller
Автор

Who write the entire source code in __init__.py file?

jhawar-ji
Автор

As someone who's attempted to typehint some very complex patterns, i feel your pain on mypy vs pyright incompatibilities. I'd love to know when and why your solution will break, as you didn't mention that in the vid.

i see your comments in the source about "Dumb thing to make pyright happy" and "insane recursive type..." but i question why you judge these things like this?

mypy supports recursive types nowadays, and thats the only place i'd guess there to be an issue.

Besides: how are you supposed to typehint something like JSON if not recursive? thats perfectly fine.

I suppose i'll have to try it myself once i get back on a device bigger than a phone.

laundmo
Автор

13:10 why your type hunts won't work in mypy ?

lame_lexem
Автор

Curious why you’re using a list to store subscribers rather than using a set. If the number of subscribers is large, seems like checking for membership in a set scales better than checking for membership in a list.

jimratliff
Автор

Why wouldn't this be called parametric? Like everything else that has a dependant heirachy of parameters? Not your fault, I know this is the term for it, I've just never paid attention to what it meant, and now I'm angry. Words mean things, damnit

gh
Автор

These python generic types are cursed compared to a typed language

Finnnicus