PEP 696 is a huge quality-of-life improvement (intermediate) anthony explains

  Рет қаралды 8,462

anthonywritescode

anthonywritescode

Күн бұрын

Пікірлер: 38
@DavidDellsperger
@DavidDellsperger 4 ай бұрын
alternative title: Nerd gets excited he doesn't have to type ", None" as often
@anthonywritescode
@anthonywritescode 4 ай бұрын
it's true!
@samuelgunter
@samuelgunter 4 ай бұрын
@@anthonywritescode isn't it True?
@abrahammurciano
@abrahammurciano 4 ай бұрын
Generator[T, None, None] is one of those things that everyone knows about but most don't know why. It would be cool to have a video explaining what the other types are for
@anthonywritescode
@anthonywritescode 4 ай бұрын
I have one! I forgot to link it in the description but it's there now!
@abrahammurciano
@abrahammurciano 4 ай бұрын
This is exactly why I've always annotated my generators as Iterator[T]. Finally I can use Generator!
@rosmelylawliet
@rosmelylawliet 3 ай бұрын
Indeed, but I remember a bug with MyPy for that, and if I'm not mistaken, Anthony was its author :P
@ayhanfuat
@ayhanfuat 4 ай бұрын
It was so fun to watch you get happy about this. 😀
@tyrisnolam
@tyrisnolam 3 ай бұрын
Hello Anthony, thank you for the great videos, I learn a lot from you! Do you think you'll have time to explain async context managers?
@anthonywritescode
@anthonywritescode 3 ай бұрын
maybe? probably not though -- tbh they're basically just context managers that let the event loop yield (if that makes any sense). I tend to stay way from python's async personally -- been really unimpressed with it and can't quite stomach the coloring problem it introduces. honestly multiprocessing / multithreading has been easier for me to write personally
@victordvickie
@victordvickie 4 ай бұрын
I never seen a grown man more happy than this, good addition btw lol
@bswck
@bswck 4 ай бұрын
So excited about that change. I often violated the rule of maximum specificity in the return type and simply used a higher-in-hierarchy `Iterator[T]`, which is obviously not an equivalent: it was only suitable for cases where I didn't have to access `.send()`, `.throw()` or `.close()`; but that was the majority of cases. Nevertheless, so cool I can just use `Generator[T]` now. There are lots of other use cases, for example `textual.App[T]` with the `T` defaulting to `None`.
@slavapasedko3139
@slavapasedko3139 4 ай бұрын
Hi Anthony. Thank you for such great content. It’s really hard to find intermediate/advanced python topics on youtube because most of the content is created for beginners and there’s no point to watch it if you already have at least some production experience. Keep up the great work. I’d like to ask you to record a video about Python memory management, how to write cpu/ram efficient code, tips & tricks, what to avoid and all python memory-cpu-related stuff, memory leaks, profiling, etc. (I watched a video about preloading & gc.freeze() it was really fun and cool stuff you did.)
@anthonywritescode
@anthonywritescode 4 ай бұрын
it's difficult to pinpoint a strategy specifically -- at least when writing pure python you don't really have much control over it other than not globally caching things forever (and not using buggy C libraries!) -- that said here's a few others I've done about memory (explains videos are collected at github.com/anthonywritescode/explains) - using memray to debug a memory leak in krb5: kzbin.info/www/bejne/mKiYcnuaj6Zqm5Y - don't lru_cache a method: kzbin.info/www/bejne/qYfNpaNsqayiZsk - fixing a 9GB memory leak in cargo: kzbin.info/www/bejne/q6mtmXSOmaefmMU
@lukajeliciclux3074
@lukajeliciclux3074 4 ай бұрын
YESSSS!!!!! Generator[int,None,None] is just WHY?!
@d17-d7e
@d17-d7e 4 ай бұрын
\o/ ... That's cool!
@flamendless
@flamendless 4 ай бұрын
696.... It is nice
@bennyyouknow
@bennyyouknow 4 ай бұрын
Love your energy in this one 😊 Indeed a nice QoL improvement 🎉
@bacon4life
@bacon4life 4 ай бұрын
Cool, I have dozens of Generator[T, None, None] in my projects.
@jakubtybinski9246
@jakubtybinski9246 4 ай бұрын
Pog
@dmytroparfeniuk2670
@dmytroparfeniuk2670 4 ай бұрын
Oh, nice)
@bashirabdelwahed40
@bashirabdelwahed40 4 ай бұрын
oh finally!!!!!!
@hansdietrich1496
@hansdietrich1496 4 ай бұрын
Yeah, that always caused eye cancer.
@danielmajer1648
@danielmajer1648 4 ай бұрын
Everytime I write something else than python I wish it was python. Unfortunately mypy is still not standard for most of the folks like typescript
@AceofSpades5757
@AceofSpades5757 4 ай бұрын
That's fantastic. It's ugly and most people don't understand the other 2 anyhow
@sillybuttons925
@sillybuttons925 4 ай бұрын
wow that is great. Always found that annoying.
@s-h-f
@s-h-f 4 ай бұрын
Didn't understand much as I am still a beginner. But seems like they get rid of ugly (unnecessary) annotations. Thanks for demo.
@bswck
@bswck 4 ай бұрын
annotations are beautiful, not ugly.
@kRySt4LGaMeR
@kRySt4LGaMeR 4 ай бұрын
really cool, but it highlights how foreign type hints are to the core language
@senseikoudai6186
@senseikoudai6186 4 ай бұрын
Maybe an obvious question, but why were there two None values in the first place?
@slavapasedko3139
@slavapasedko3139 4 ай бұрын
Generator can yield, return and accept value using .send() Hence three typings for each of those possibilities
@anthonywritescode
@anthonywritescode 4 ай бұрын
I cover this in the video linked in the description in more detail as well!
@guscardvs
@guscardvs 4 ай бұрын
This could be true for Coroutine also
@anthonywritescode
@anthonywritescode 4 ай бұрын
indeed! though I'm not sure Coroutine got the same treatment :(
@Quarky_
@Quarky_ 4 ай бұрын
Is there a difference between importing Generator from collections.abc and typing?
@iamcurrentlypooping
@iamcurrentlypooping 4 ай бұрын
typing.Generator is a deprecated alias to collections.abc.Generator
@Quarky_
@Quarky_ 4 ай бұрын
@@iamcurrentlypooping thanks! I was recently going through the docs, and I don't recall seeing any deprecation warning, that's why I was confused. Looks I just overlooked it :⁠-⁠P
how do I make an empty generator? (intermediate) anthony explains #577
7:38
adding test == others fail??? (intermediate) anthony explains #572
10:40
anthonywritescode
Рет қаралды 4,3 М.
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 96 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,5 МЛН
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Натурал Альбертович
Рет қаралды 3,9 МЛН
Fedora Linux In a Nutshell
4:01
Siberoloji
Рет қаралды 1
Why Didn't He Get the Job? Let's Find Out! // Code Review
27:25
The Cherno
Рет қаралды 149 М.
the system design interview (intermediate - advanced) anthony explains #556
28:58
debugging flaky cascading failure after upgrading pytest!
26:15
anthonywritescode
Рет қаралды 3,7 М.
oops I'm the pyuwsgi maintainer now (intermediate) anthony explains #579
22:55
Programming Is Cooked
9:30
ThePrimeTime
Рет қаралды 159 М.
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 645 М.