python 3.12 release highlights (beginner - advanced) anthony explains

Поделиться
HTML-код
  • Опубликовано: 21 окт 2024

Комментарии • 106

  • @rednafi
    @rednafi Год назад +49

    Thanks for not trimming it down for the stupid youtube algorithm.

  • @SebaSalinas91
    @SebaSalinas91 Год назад +40

    Thanks for all the amazing content you share with us... Pretty cool that you get to work in core python projects and even talking to Guido! Cudos for you! Looking foward to use your pre-commit library, im still figuring it out.. Greetings from Chile!

    • @con-f-use
      @con-f-use Год назад +1

      Yeah, it's very nice of you to explain this, thanks. Cuts down the time to research it oneself. You'll have to do it for professional reasons anyway, I guess, so mighty fine to spend the extra time, make a video, and save some strangers collective days of tedium.

  • @RedShipsofSpainAgain
    @RedShipsofSpainAgain Год назад +4

    2:13: infinitely nestable f-strings
    9:16 the modules that are going away: 'distutils' module; 11:48: the 'imp' module
    12:45 type variables/parameters/aliases (allows Generics to be specified easier)

  • @pylang3803
    @pylang3803 Год назад +11

    def x[T, U, V](y: U, z: V) -> list[T]: pass
    *holds head*

  • @DavidDellsperger
    @DavidDellsperger Год назад +26

    This was great, I look forward to getting to play with these in 3 years when python 3.12 is a few months from EOL

    • @amir.hessam
      @amir.hessam Месяц назад

      @DavidDellsperger glad to see familiar faces here ...

  • @henryschreiner
    @henryschreiner Год назад +22

    You did the $ variables in pdb correctly, they stay between stack changes, not continuing execution (they are cleared then).
    batched doesn’t error, you were unpacking it assuming it returned the same number each time. For its use case (batching items for multiprocessing), that’s exactly what you want and it’s a benefit over the existing helpers. Just don’t unpack assuming identical batch sizes. :)

    • @acidnynex
      @acidnynex Год назад +1

      Was this use case really the primary reason for its inclusion in the standard library? I've done this using grouper from more_itertools for years, there is also so much more additional nice functionality in that package that it would be nice to have had a bit more of it included in the standard library.

    • @Squeemos
      @Squeemos Год назад

      Oooh that's what I was wondering about as well. Seeing something that can help do batches for me (without weird math to get me there) is really handy, since I typically use a whole batch at a time rather than unpacking! Neat!

  • @aaronater1088
    @aaronater1088 Год назад +1

    Appreciate the dissect on what's comin. Neat find on the NUL byte too

  • @Gaivs
    @Gaivs 11 месяцев назад +1

    To me, the point of itertools.batched _is_ that the final "element" can contain fewer elements! Many algorithms are memory intensive, so being able to cap the number of elements for each batch means you can limit how many subelements are handled, rather than being a zip-replacement. So rather you would have:
    for batch in itertools.batched(it, 2):
    if len(batch) == 1:
    process_one(batch[0])
    elif len(batch) == 2:
    process_two(batch)
    else:
    continue
    Or something smarter. In machine learning fields, this is a common way to handle training data, and while there are other tools for this there, it is nice to have a python implementation for this. As recently as a week before the release of python 3.12 I had to install the more itertools package to get this function for a project.

  • @StepanKabachkov
    @StepanKabachkov Год назад +23

    This new generics syntax and the type keyword is just a shocker honestly. Couple more versions - and the language becomes non-recognizable to people used to 3.7 or something :)

    • @theendlessriver13
      @theendlessriver13 Год назад +2

      Yeah - that also hit me as looking just "wrong" - but I'll get used to it I guess...

    • @ac130kz
      @ac130kz Год назад

      nah, just a few touches

    • @peculiar-coding-endeavours
      @peculiar-coding-endeavours Год назад +5

      Basically generics syntax is now closer to what it is in many other languages. What a shocker

    • @noobling8313
      @noobling8313 Год назад

      Just don’t use the syntax unless it’s fun.

  • @d3stinYwOw
    @d3stinYwOw Год назад +3

    Removal of distutils can hurt only in one circumstance - where you don't have access to pip at all, and you're stuck with whatever standard library can provide to you, either as learning excercise or your boss have panic attack when hears about anything 'third-party' :)

  • @amir.hessam
    @amir.hessam Год назад +8

    I love the fact that Anthony mostly wings his videos! Very cool ♥

  • @RuslanKovtun
    @RuslanKovtun Год назад +1

    You are making amazing videos and I'm watching them not for fun but as an actual short/dense overview of new features or some tweaks and tricks. I have learn a lot from your videos. I appreciate your work.

  • @_Ani_
    @_Ani_ Год назад +1

    Thanks for the overview Anthony, a fun and insightful video as always!

  • @Squeemos
    @Squeemos Год назад +2

    Great video! The function annotations look... goofy. However I'm glad to hear that list comps (and I assume dict comps as well, but I'd have to look) got a speedup that seems relatively trivial!

  • @piyushgupta7210
    @piyushgupta7210 Год назад

    that's just amazing.. thanks for taking out time and giving an overview of cool features of 3.12

  • @hardikojha220
    @hardikojha220 Год назад +1

    Unpacking of the TypedDict is a blessing

  • @swapnilchavan7076
    @swapnilchavan7076 Год назад +5

    Amazing content. I love to watch your videos. You are so informative. Thanks for doing this. I appreciate your efforts. 🙏

  • @soberhippie
    @soberhippie Год назад +3

    Generics are now more in line with those in Java and Rust, which is nice.
    Does isinstance work if you declare something as that type explicitly? Like `type MyType = int; a: MyType = 2; isinstance(a, MyType)`?

    • @anthonywritescode
      @anthonywritescode  Год назад +4

      no. type hints aren't part of the runtime like that they're mostly just comments

  • @DorkOrc
    @DorkOrc Год назад

    I can’t say I understood a lot of this, but it was very good background chatter to put on while mindlessly programming, so thank you for helping me focus haha

  • @lucasfcnunes
    @lucasfcnunes Год назад +2

    In ISO 8601 monday is the start of the week + Week with weekday notation e.g. 2023‐W32‐1 is a monday

    • @alexandrugheorghe5610
      @alexandrugheorghe5610 Год назад

      Thank goodness for that. No offense, but I can't stand the week starting on a Sunday!

  • @yorailevi6747
    @yorailevi6747 Год назад +5

    Can someone add timestamps? A tldr and a way to jump into detail is really helpful

  • @mrc1500
    @mrc1500 Год назад +2

    Quite like the Generic types overhaul. I gave a wry chuckle and wondered when Python would become Scala 😏

  • @traal
    @traal Год назад +3

    I like the override decorator. Explicit is better than implicit, right? 😊

  • @TankorSmash
    @TankorSmash Год назад

    Informative and engaging, thanks for uploading. I love the nice error messages.

  • @debakarr
    @debakarr Год назад +5

    Some of these like the f string and generic type is really hard to read. Just wondering what impact will it have in libraries like Pydantic.
    Btw, you are one of the coolest person in the Python community.

  • @sadhlife
    @sadhlife Год назад +4

    Instead of /dev/stdin you can just not give tokenize any file argument and it'll default to stdin

  • @Phaust94
    @Phaust94 Год назад +3

    Thanks for the video! Love it! Love your style!
    The features not so much tho

  • @bernardcrnkovic3769
    @bernardcrnkovic3769 Год назад +1

    i was just wondering what was the use case for nested f-strings? I feel like it is satisfying to allow any combination of quotes in nested expressions but I can't think of use case for nested ones.

    • @catcatcatcatcatcatcatcatcatca
      @catcatcatcatcatcatcatcatcatca Год назад +1

      My guess would be that now you can have an uggly general formatting string bound to a symbol, expand it with one fstring and then call that new fstring.
      I have not tried this, but my idea would look something like:
      Charlie=“charlie_stateA”
      f’{f’{Charlie}_3’}’ to exapand the variable charlie_stateA_3
      Basically what this allows is manipulating the command or symbol the outer f-string will expand. It’s kind of a macro, and does what eval would do.
      Just thinking this makes my head hurt a bit, so I’m not sure if I will even bother trying it. But you might be able to “generate” an anonymous function with combining different symbols, and then evaluate that with-in the larger f-string. Like you could use a symbol to determine what lambda-function you will use to filter a list, and just do that inside an f-string.
      So in short, think of the most cursed way to use eval you can imagine. Now you can do that all within a single f-string. I feel very very sorry for anyone who is better of having this feature available, but for sake of completeness it makes sense to add.

  • @princeroshan4105
    @princeroshan4105 Год назад +4

    I added those enums in calendar 😁, that was I guess my first PR to Cpython.

    • @niazhimselfangels
      @niazhimselfangels Год назад +1

      Thanks, man! 😃

    • @pratyushrath1457
      @pratyushrath1457 Год назад +1

      Great work! Keep contributing.

    • @RedShipsofSpainAgain
      @RedShipsofSpainAgain Год назад

      Good job! Kinda of amazing that Python has had this bug for 23 years. How did no one think to fix this sooner??

    • @princeroshan4105
      @princeroshan4105 Год назад +2

      @@RedShipsofSpainAgain It was not a bug. It was 2 unnecessary variables exposed in module namespace because it was required in many functions inside the module, that's why it was kept global, No one thought that somebody will use it, but few of them are using it. Now we have added a deprecation warning for the same.

    • @RedShipsofSpainAgain
      @RedShipsofSpainAgain Год назад

      @princeroshan4105 Ahh ok thanks for explaining. But why were only 2 months needed? Seems like an arbitrary number of months to require. Couldn't they have just added the other 10? Why stop at 2 months? Why not 3? Or 7?

  • @j.i.-cruz
    @j.i.-cruz Год назад +1

    hyped for the vid! chapters would be super helpful

  • @jrheard
    @jrheard Год назад +1

    ❤ for casual inheritance diss ❤❤

  • @catcatcatcatcatcatcatcatcatca
    @catcatcatcatcatcatcatcatcatca Год назад

    Better typing-syntax is great, we want more typing but less typing. Similarly improved error messages help with learning and sleep deprivation.
    The new itertool change also allows doing some very satisfying but pretty cursed stuff. Just have a list that contains lists of anonymous functions and some structure of values, in alternating fashion, and call those functions on the values in some meaningful way.
    and now this one line of code runs sets of functions on a list of values, then a different set of functions on a different list of values, and so on. You will feel so smart when you get it to work properly. This can compeletely replace classes and I bet everyone reading the code is throughoutly impressed.
    Or you can use it to parse a list in chunks like a normal person.

  • @user-kn4wt
    @user-kn4wt Год назад

    really enjoyed this! thanks for all your videos 🙏🙏

  • @18Maxim18
    @18Maxim18 11 месяцев назад

    Thanks for the video, I waited for override decorator, as in my project we wrote it by our own. Minus one shitty func in our repo)

  • @DrSnej
    @DrSnej Год назад

    There is no mention of the changes to GIL in py3.12 in this video.. why? It seems like quite a change, would like to hear your insight on it.

  • @mrswats
    @mrswats Год назад

    Always love these, so I know what to tell my colleagues about the new python version!

  • @Soulthym
    @Soulthym Год назад

    Line 269 of pdb.rst after commit 7db9d37... in issue 103694 says:
    "The*convenience variables* are cleared when the program resumes execution so it's less likely to interfere with your program compared to using normal variables"
    Looks like this is the reason it wasnt defined after you resumed :)

  • @piotrbogdanski8785
    @piotrbogdanski8785 Год назад

    Great content as always! What about PEP 684? Looks like it's listed as one of the major changes in the release notes for 3.12 and sounds quite cryptic to me, I'd love a video about this

    • @anthonywritescode
      @anthonywritescode  Год назад +2

      most people don't care -- subinterpreters is mostly for embedding python

  • @dangerousdansg
    @dangerousdansg Год назад

    Great video, I learnt so much!

  • @MakeDataUseful
    @MakeDataUseful Год назад

    Generics is a little scary looking!

  • @Adherbal22
    @Adherbal22 Год назад

    Thanks dude what a great content ❤❤❤

  • @daineminton9687
    @daineminton9687 Год назад +1

    ...oof... the nested f-string is nice, but seems to me it'll get pretty messy very quickly. Makes me wonder if you could pull a walrus op inside f-string... gonna play with 3.12 later
    This is oddly interesting behavior.
    Running below...
    arr = '1 1 2 1'.split()
    f"nums are: {f'{" ".join([str(y) for _ in arr if (y:=int(_) + 3) == 5])}:{" ".join([str(y) for _ in arr if (y:=int(_) +3) == 4])}'}"
    Returns below...
    'nums are: 5: 4 4 4'
    Code looks clunky, hard to read, & quotations seem to be very touchy when switching between single & double marks. Tested this in pre release 04 of version 3.12 but it works.

  • @maxvangent4171
    @maxvangent4171 Год назад +1

    With the new f-string parsing we can finally write php in python 🙃

  • @skarfie123
    @skarfie123 Год назад

    The batched function is still useful if you just don't unpack in the for loop

  • @asrk3855
    @asrk3855 Год назад

    I am new to this channel
    When I first saw thumbnail
    I was like, why is attorney tom talking about python

  • @rudranagkatroju9970
    @rudranagkatroju9970 Год назад

    Hey Anthony. Can you explain how to add a custom function to python builtins.

  • @rosmelylawliet
    @rosmelylawliet Год назад +1

    I love pyupgrade, i use it regularly

  • @IvanHabunek
    @IvanHabunek Год назад

    Cool video, thanks!

  • @Md.AlmasAli
    @Md.AlmasAli Год назад

    Excellent introduction! ❤

  • @atugushev
    @atugushev Год назад

    Thanks for great changelog!

    • @atugushev
      @atugushev Год назад

      Really enjoyed the video. Pretty excited by @override and typed kwargs. And pre-commit now in cpython, wow this is win! It's fun that pdb became php xD

  • @windowviews150
    @windowviews150 9 месяцев назад

    Cool kb. What is it? freestyle pro?

  • @desertfish74
    @desertfish74 Год назад

    Why the square brackets for the generic type variables where everyone else is using less than and greater than brackets for that…?

    • @anthonywritescode
      @anthonywritescode  Год назад

      some other languages do that too -- plus there's already presence in python for squackets

  • @djazz0
    @djazz0 Год назад +1

    Finally, more months lol

  • @simdimdim
    @simdimdim Год назад

    10:37, just me or was that you keying in your password on camera?

  • @avasam06
    @avasam06 10 месяцев назад

    Small typo in chapters:
    - 9:18 "distutels"
    - 29:47 "Pi upgrade"

    • @anthonywritescode
      @anthonywritescode  10 месяцев назад +1

      I haven't added chapters -- those are generated

    • @avasam06
      @avasam06 10 месяцев назад

      @@anthonywritescode uh, found it curious I couldn't find the timestamps in the description. I didn't know RUclips autogenerates chapters.

  • @putnam120
    @putnam120 Год назад +1

    But why the f string change? Makes no sense to me

  • @funkdefied1
    @funkdefied1 Год назад

    At this point the Python std will just be a wrapper around C.

  • @cparks1000000
    @cparks1000000 Год назад

    19:45 I'm not impressed that the new type aliases don't work with "isinstance".

  • @qexat
    @qexat Год назад

    don't forget to link the video about generics :P

  • @destinyinworld4064
    @destinyinworld4064 Год назад +1

    Thanks 🎉

  • @funkdefied1
    @funkdefied1 Год назад

    Both the type alias and the generic typing syntax looks just like Rust.

  • @MyriadColorsCM
    @MyriadColorsCM Год назад

    I think pygame no longer works in 3.12 because of the distutils deprecation.

  • @w2lkm2n
    @w2lkm2n Год назад

    You exposed your sudo password at 10:37

  • @qexat
    @qexat Год назад

    override is all nice until the linter reports missing `override` on bare class methods like `__repr__` 💀

  • @computerfre3
    @computerfre3 Год назад +3

    Did you just enter your root password on camera?

    • @anthonywritescode
      @anthonywritescode  Год назад +7

      it's "bad password" -- I intentionally use a bad password here because of this

    • @desertfish74
      @desertfish74 Год назад

      @@anthonywritescodemine is 8 asterisks

  • @commandcracker42
    @commandcracker42 Год назад

    WOW Python became JS ._.

  • @kosmonautofficial296
    @kosmonautofficial296 Год назад +1

    I HATE MARCH!

  • @qexat
    @qexat Год назад

    frob

  • @yomajo
    @yomajo Год назад +1

    What's the practical use for these type vars ..? Is this how core devs are fighting AI? by making language unreadable? Deeply saddened.

  • @DrDeuteron
    @DrDeuteron Год назад

    This typing has got to stop

  • @raymondpearson1971
    @raymondpearson1971 Год назад

    "promosm" ✋

  • @yomajo
    @yomajo Год назад

    These hipsters introduce new typing shit, that doesn't even work with builtins like isinstance. It's ridiculous. As if bunch of javascript devs flooded core and started making decisions.

    • @吳政霖-b9t
      @吳政霖-b9t Год назад

      I think it is for optimization considerations and consistency, the original type hints are always cannot be used at runtime.

  • @proofit404
    @proofit404 Год назад

    Лучший

  • @shmuelk3018
    @shmuelk3018 Год назад

    Thanks 🎉