Metaclasses in Python

Поділитися
Вставка
  • Опубліковано 24 чер 2024
  • Metaclasses customize the class creation process.
    We go over what metaclasses are and give some notable examples, including: abstract base classes, adding function overloads, and dataclasses or code generation.
    CONTEST WINNERS (CONTEST ENDED 10/9/21) :
    PyCharm: Yannick Kuhn, peter duffy
    CLion: BalkanSwine, Laurin Neff
    OFFICIAL CONTEST RULES:
    1. All entries must comply with the UA-cam community guidelines ( ua-cam.com/users/tcommunity_gu...) and UA-cam Terms of Service (ua-cam.com/users/static?gl=US&t.... Entries that violate UA-cam guidelines are automatically disqualified.
    2. UA-cam is not a sponsor of the contest and viewers are required to release UA-cam from any liability related to the contest.
    3. Privacy notice: no personal data will be collected for this contest.
    4. In order to enter, you must (a) be one of my subscribers, AND (b) make a top-level comment to the video including #pycharm or #clion or both. If you only include one you will only have a chance to win that corresponding license.
    5. The contest is free, there is no fee required to enter.
    6. Winners will be chosen randomly 1 week after the date the video went live from all users who have entered and not been disqualified.
    7. Each winner will be notified via a comment reply from me that details what prize was won (e.g. "Congratulations! You have won XYZ. Please email me."). I will ask the winner to contact me by email, and I will reply through email with a random token which must be posted as another reply to the winning comment from the winning account in order to verify account ownership and prevent fraud.
    8. Each winner will have 72 hours to respond AND prove account ownership or their prize is automatically forfeited and another winner will be chosen.
    9. A winner can only win 1 prize per contest.
    10. The prize pool for this contest is: 2 licenses for PyCharm Professional ("Free 1-Year Personal Subscription") and 2 licenses for CLion ("Free 1-Year Personal Subscription"), which are products made by JetBrains. A prize consists of 1 license, which will be delivered in the form of a redeemable code that can be redeemed at www.jetbrains.com/store/redeem/ before May 01, 2022.
    11. You may not enter the contest if doing so would be a violation of any relevant federal, state, and local laws, rules, and regulations, including U.S. sanctions.
    ― mCoding with James Murphy (mcoding.io)
    Source code: github.com/mCodingLLC/VideosS...
    Python metaclass docs: docs.python.org/3/reference/d...
    Previous video on new: • __new__ vs __init__ in...
    Another great metaprogramming video: • Python 3 Metaprogramming
    Python descriptor docs: docs.python.org/3/howto/descr...
    Python ABC docs: docs.python.org/3/library/abc...
    SUPPORT ME ⭐
    ---------------------------------------------------
    Patreon: / mcoding
    Paypal: www.paypal.com/donate/?hosted...
    Other donations: mcoding.io/donate
    Top patrons and donors: Jameson, Laura M, John Martin, Dragos C, Vahnekie, Pieter G, Casey G, Sigmanificient
    BE ACTIVE IN MY COMMUNITY 😄
    ---------------------------------------------------
    Discord: / discord
    Github: github.com/mCodingLLC/
    Reddit: / mcoding
    Facebook: / james.mcoding
    CHAPTERS
    ---------------------------------------------------
    0:00 Intro
    1:28 What is a metaclass
    3:58 Simplest possible metaclass
    4:59 Load time metaclass
    6:08 Abstract base classes
    8:03 Function overloads
    14:10 Dataclass code generation
    15:01 Giveaway instructions
  • Наука та технологія

КОМЕНТАРІ • 824

  • @GanerRL
    @GanerRL 2 роки тому +486

    i will literally never have a practical use case for this but it still makes me happy it exists
    edit: ok within a year I have used it several times I retract my previous statement

    • @tswdev
      @tswdev 2 роки тому +20

      The answer is basically proper encapsulation. You can shift the complexity to the caller (outside the class) or you can keep it in the class where its manageable while keeping the caller (outside the class) simple.
      Creativity is everything and this is just another tool to support that.

    • @user-vt9bp2ei1w
      @user-vt9bp2ei1w 2 роки тому +12

      I actually used Metaclass to modify the __iter__ method of my Enum class to skip some values.
      Basically like this:
      from enum import Enum, EnumMeta, auto
      class MyEnumMeta(EnumMeta):
      def ignore(Cls, e):
      return False
      def __iter__(Cls):
      return (e for e in super().__iter__() if not Cls.ignore(e))
      class MyState(Enum, metaclass=MyEnumMeta):
      Empty = auto()
      A = auto()
      B = auto()
      C = auto()
      @classmethod
      def ignore(Cls, e):
      return e is Cls.Empty

    • @skully90
      @skully90 2 роки тому +5

      I used it all the time when I was a Java developer when I needed similar blocks of code to handle single item of type X or a list of items of type X. 99% of the time it was two functions with one function handling single item and the "overloaded" 2nd function handling the List of that item

    • @tochka832
      @tochka832 2 роки тому +5

      dunno, i use overloads all the time in Nim and C++, its rather handy tool for segmenting code
      otherwise you would need to create a single function in python that has all the implementations depending on args* kwargs** signature which is rather clunky

    • @MrTyty527
      @MrTyty527 2 роки тому

      @@user-vt9bp2ei1w crazy

  • @andrewglick6279
    @andrewglick6279 2 роки тому +592

    This video was so magical I'm tempted to call it a ___video___

    • @qkimat
      @qkimat 2 роки тому +3

      Or a video of a __video__

    • @zoulei881027
      @zoulei881027 2 роки тому +5

      5 letters are too long. use __vid__

    • @30IYouTube
      @30IYouTube 2 роки тому +13

      Ah... *dunder video*

    • @boggri
      @boggri 2 роки тому

      magic, like a magic ___methods___ in Python )))

    • @tips1483
      @tips1483 2 роки тому

      @@zoulei881027 yeah and the __str__ will return “video”

  • @QuantumHistorian
    @QuantumHistorian 2 роки тому +68

    7:55: _"No need to be confused"_
    Me: Most confused I've ever been in an mCoding video
    #pycharm

  • @pericofalcor
    @pericofalcor 2 роки тому +232

    Metaclasses looks very powerfull, unfortunately most people using "powerfull" features in a big codebase usually leaves the most powerfull mess to be maintained. Great video! #pycharm

    • @5h5hz
      @5h5hz 2 роки тому +18

      Hello! "Powerful" is spelt with 1 'l' not 2 :)

    • @royz_1
      @royz_1 2 роки тому

      Well said

    • @pericofalcor
      @pericofalcor 2 роки тому +65

      @@5h5hz Thanks. At least I was consistent.

    • @5h5hz
      @5h5hz 2 роки тому +32

      @@pericofalcor hahaha such a programmer response, I love it!

    • @ilyboc
      @ilyboc 2 роки тому

      He meant powerfull of poo poo

  • @macchicken98
    @macchicken98 2 роки тому +82

    My mind is blown. So many possibilities once you know what Python does under the hood. I would find it super interesting to learn more about how C-bindings like numpy uses them are built and how one could add them too. #pycharm

    • @pranavnyavanandi9710
      @pranavnyavanandi9710 2 роки тому +1

      How do you go about finding what python does under the hood, in a relevant manner?

    • @ganeshlakshmanan3391
      @ganeshlakshmanan3391 Рік тому

      My mind is not blown as these features have been available in other OOP languages for ages. However I still like Python for its simplicity and would dread going into typing library, generics etc. I prefer simplicity.

  • @yogachen7885
    @yogachen7885 2 роки тому +55

    This is the most complicated subject of Python I’ve ever seen. Thank you for your work. #pycharm #clion

  • @foxcirc
    @foxcirc 2 роки тому +11

    Since I've -lot's of work- nothing to do right now, I counted how often you've said the word 'class' and 'metaclass' in this video:
    *·* class ⟶ *62 times*
    *·* metaclass ⟶ *33 times*
    Oh my god, I watched the video on 2x speed and at 1:37, my brain just started to hurt.
    I really like your content by the way. There are so many useful python features I've hever heard of before. 👍

    • @mCoding
      @mCoding  2 роки тому +12

      Do occurrences of metaclass also count towards class?

    • @photon6156
      @photon6156 2 роки тому

      Don't worry, if you watch plenty of videos at 2x, you'll get used to it

    • @foxcirc
      @foxcirc 2 роки тому +4

      ​@@mCoding
      No, I counted them seperately, I counted things like "class body" though. Still 70 times seems like a very high number.
      EDIT: I counted again and updated the numbers, though not much changed.

    • @georgplaz
      @georgplaz 2 роки тому +2

      @@foxcirc was that "edit" a form of youtube commit message? 😁

  • @mytelevisionisdead
    @mytelevisionisdead 2 роки тому +2

    Man the information density in your videos is mindboggling. Every 20 seconds there's something I'd need to sit an hour for to fully absorb the concept and the code. Well done, thanks

  • @dragon_pi
    @dragon_pi 2 роки тому +14

    "the type of big A is a type but the type of small a is big A, whereby the type of type is type"
    That's exactly the feature you will probably not use for a long time, but years from now you will remember and it will save your life!
    Best thing about python, it's not like other languages where many base features are hard-coded, but you can customize EVERYTHING
    #pycharm

    • @georgplaz
      @georgplaz 2 роки тому +4

      its not always a good feature

    • @dragon_pi
      @dragon_pi 2 роки тому

      @@georgplaz yeah, too much customisation just gets everyone confused, you cant replace every descriptive function name with some __magic__ and have people (and yourself) still understand it.

  • @ciscoortega9789
    @ciscoortega9789 2 роки тому +1

    I feel like your videos have given me a really deep understanding and appreciation of all the internal magic that goes on behind the scenes on Python. Thanks for the content!

  • @theepicguy6575
    @theepicguy6575 2 роки тому

    This is actually that rare gem content found under the depths of the internet. Been trying to wrap around meta-classes for a week now, with so little luck. The docs/content revolving around such concepts are so scarce, But you made it so clear as day. Thank you :) -don't need pycharm cause VSC is nicer lol-

  • @SystemfehlerK
    @SystemfehlerK 2 роки тому +54

    All programming languages seem to converge towards each other. Combine this with Cython and static typing, and you just made a slower C++, but with more libraries. #pycharm

    • @chrisvinciguerra4128
      @chrisvinciguerra4128 2 роки тому +26

      As the world progresses more we all figure out the best way to do things has been C++ all along.

    • @duality4y
      @duality4y 2 роки тому +1

      @@chrisvinciguerra4128 c++ is not a good choice for embedded systems c ftw

    • @supernoob0536
      @supernoob0536 2 роки тому +2

      @@duality4y May aswell just hammer the opcodes into RAM yourself

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 2 роки тому +17

      @@chrisvinciguerra4128 Yeah that beautiful manual memory management when you're designing a high-level user-facing application was always the right way all along.

    • @mCoding
      @mCoding  2 роки тому +4

      Gratz! You (Yannick) get a PyCharm license! Contact me to claim your prize! mcoding.io/contact

  • @brucewayne1777
    @brucewayne1777 2 роки тому +19

    I taught Python for 2 years at the university level. I thought I knew more deep wizardry than any person should know. After seeing this, it's clear that I know nothing.
    #pycharm

    • @matthieurochette
      @matthieurochette 2 роки тому +1

      Same here, my friends call me when they have a question about Python because they know I love it and know it quite well, but when they call me a "Python master" I humble myself by remembering this channel exists :')

  • @jaysonbunnell8097
    @jaysonbunnell8097 Рік тому +2

    one of my favorite things about python is how modular the language itself is. You can just overload anything you want, and having the syntax be so malleable is so fun!!

  • @legotechnic27
    @legotechnic27 2 роки тому

    I've not used python in years, and primarily use TypeScript myself currently.
    I had an alright time using Python when I did, but didn't think too much of the language, but your videos including this one really make me appreciate python more!
    This whole system shown in the video is very elegant imo, and very powerful.

  • @_gregor
    @_gregor 2 роки тому +1

    Awesome video! It's a bit more advanced than usual, but it's good to hear something like that once in a while!

  • @jezreel3584
    @jezreel3584 2 роки тому +5

    I've definitely learned more from your channel than any of the other python channels, and courses I've taken combined. Please keep making such great content. #clion

  • @rafaelhdebarros
    @rafaelhdebarros 2 роки тому +3

    This is a terrible idea, super slow, and very very dangerous.
    I absolutely love it.

    • @mCoding
      @mCoding  2 роки тому +2

      You had me in the first half

  • @Pyroseza
    @Pyroseza 2 роки тому +1

    James, every video I watch you blow my mind with what is possible in Python, I don’t know yet what I’ll do with all this new knowledge but dang is it fascinating! Thanks for the quality content #pycharm

  • @secozzi2111
    @secozzi2111 2 роки тому +4

    It's interesting to see overloading implemented in Python, I saw a stackoverflow comment suggesting to use multiple dispatch instead and now I might see why considering the slowdowns. Great video as always :) #pycharm

  • @UntakenNick
    @UntakenNick 2 роки тому

    So you were trying to overload a function with the wrong syntax and didn't work, the you used the correct way to do it and worked.
    Mind bending.

  • @nhoover
    @nhoover 2 роки тому +1

    Very clear explanation. After over 10 years of python programming I still learn new tricks from all of your videos. Thanks!

    • @mCoding
      @mCoding  2 роки тому

      Great to hear!

  • @Chris-yw5is
    @Chris-yw5is 2 роки тому +185

    For once Python is making me appreciate the simplicity of C++ and not the other way around #clion

    • @kurtmayer2041
      @kurtmayer2041 2 роки тому +16

      don't worry, we'll get reflections in c++ soon(tm)

    • @duality4y
      @duality4y 2 роки тому

      @@kurtmayer2041 i need that

    • @nabeelsherazi8860
      @nabeelsherazi8860 2 роки тому +13

      This is so much simpler than anything C++ reflection ever will be. At least this is consistent lol

    • @tochka832
      @tochka832 2 роки тому +14

      simplicity... of C++? in what world is it true lol

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 2 роки тому +8

      You must've just started learning C++.

  • @samuellebot4390
    @samuellebot4390 2 роки тому +9

    this is heresies, black wizardry and demonology combined

    • @Kenionatus
      @Kenionatus 2 роки тому +1

      Every use of this forbidden knowledge needs to be marked with
      # Here be dragons!

  • @oxey_
    @oxey_ 2 роки тому

    Yet another banger, I didn't even know this existed to be honest! Really interesting watch.
    As for the giveaway I 'm a student so I get their stuff for free, but it's actually incredible you got that opportunity from Jetbrains! Congrats on that.

  • @alexismandelias
    @alexismandelias 2 роки тому

    Every time I think I am quite knowledgeable in python a new video is posted and I realize how few features of python I actually use

  • @mgdibtygd
    @mgdibtygd 2 роки тому

    Fabulous! Just what I needed to understand this shiny yet murky realm of metaclasses.

  • @turtlewasnttaken
    @turtlewasnttaken 2 роки тому +4

    This was actually quite interesting. I didn't know function overloading was even possible in python! Very cool.
    #python

  • @deadmanbg
    @deadmanbg 2 роки тому +1

    I'm really happy that you are making speed comparisons. This is something I often do with python, to figure out what works best, but I don't always understand why. #clion

  • @aaronm6675
    @aaronm6675 2 роки тому

    Great video, i had no idea these aspects where so customizable!

  • @gideonfelt2819
    @gideonfelt2819 2 роки тому

    Python gets more intricate and beautiful the more I use it. (and learn from your videos)

  • @DanielLavedoniodeLima_DLL
    @DanielLavedoniodeLima_DLL 2 роки тому +1

    I think the good part is that there are so many concepts you touch that I didn't even know in Python. I had to stop several times to look the documentation and learned a lot! Thanks! #pycharm #clion

  • @wizardfix
    @wizardfix 10 місяців тому

    This is really fascinating stuff James! I thought I was pretty experienced with Python, but you are helping me take my understanding to another level. Many thanks for sharing your wisdom.

    • @mCoding
      @mCoding  10 місяців тому +1

      Hi Wizard, thank you very much for your kind words! I'm glad you enjoyed and glad to have your viewership!

  • @jachymmierva9453
    @jachymmierva9453 2 роки тому

    This is extremely interesting. I tried to learn about metaclasses about two years ago, but I didn't understand it - until now. Excellent explanation.

    • @mCoding
      @mCoding  2 роки тому

      Great to hear!

  • @dariuszspiewak5624
    @dariuszspiewak5624 Рік тому

    David Beazley, as far as I remember, advocates the use of class decorators (where possible) instead of metaclasses. The decorators are easier to handle, easily composable and easier to understand. But sometimes... yes, one has to take the bull by the horns and dive into metaclasses (not for the faint of heart). There's no wizardry at play here but one has to go through a lot of theory and practical examples to really start to see (appreciate?) the structure and intent of the creators of the language. Thank you for the video and spreading the knowledge.

  • @HeyImAK
    @HeyImAK 2 роки тому +1

    I feel like this channel both teaches you advance python and the foundations you didn't know you don't know. Thanks! #pycharn

  • @l4luchi123
    @l4luchi123 2 роки тому

    Loved the part where you showed what's behind the curtain of some standard libraries. You should make a whole series of this. 👏🏻
    #pycharm

  • @parlor3115
    @parlor3115 2 роки тому

    Damn, I've got to appreciate how flexible Python is. This is face meltingly awesome.

    • @mCoding
      @mCoding  2 роки тому

      Thanks for the kind words!

  • @andrewhicks
    @andrewhicks 2 роки тому

    Amazing. I’ll definitely be needing to watch this vid again a few times to understand it, but it’s truly mind blowing what you can do with metaclasses. #pycharm

  • @mirage3dee
    @mirage3dee 2 роки тому +1

    Very interesting information there. I would think, though, that most people have gotten around not having overloads built-into standard Python for so long, that normal Python paradigms suffice for all their coding. Overloading is nice to have, but I think it's more of syntactic sugar to other possible syntaxes. Somehow I can't help but think about the Zen of "Explicit is better than Implicit" might apply here as well, especially when usage is coupled with non-keywords args.
    Thank you for the wonderful videos, and I must admit this is my first comment on your channel, but I follow your videos constantly. #pycharm

  • @mattnorth84
    @mattnorth84 2 роки тому +1

    Being a beginner with Python I'm quite happy I managed to follow what was going on here. Even though the approach discussed here has various negatives the content as a whole was quite informative. Thank you. #pycharm

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 2 роки тому +5

    7:33 This is how the enum module is implemented -- you create enum classes by subclassing base classes that have a special metaclass attached.

  • @gawwad4073
    @gawwad4073 Рік тому

    Your videos are very useful. Short and to the point and ofter cover subjects you may not encounter when using the language even professionally. Thank you!

  • @bnev
    @bnev 2 роки тому

    Your videos are so impressive, very good explanation and really clear examples - for real you are a cut above the rest in this space and I'm glad your channel is growing so quickly!
    #pycharm

  • @lxathu
    @lxathu 2 роки тому

    Now, that we've learnt about this from this fantastic video, probably it's time for the designers of the language to learn, from the very same video, that the most basic feature of am OO language should not be paid in blood.

    • @mCoding
      @mCoding  2 роки тому +1

      Haha you're welcome to suggest but I think the designers are mostly against checking types at runtime. Also they will tell you python is a multiparadigm language, not just OO!

  • @thinkingforyou8421
    @thinkingforyou8421 2 роки тому

    This was amazing! I was just wondering if there was a way to do this in python. I didn’t even know metaclasses existed before now. Thank you for the very detailed explanation! Keep it up! #pycharm

  • @pavolkollar7748
    @pavolkollar7748 2 роки тому +2

    Damn. The type of video to really smack you in the face, when you think you know programming.
    Do more, James, your content is fantastic!
    #pycharm

  • @spaghettiking653
    @spaghettiking653 2 роки тому +27

    Thanks sir, your content is always enlightening. Frankly, it sometimes stupefies me how much there is to learn about a language that many of my friends, and my computer science teacher, dismiss as simplistic... great content as always!
    #pycharm

    • @mCoding
      @mCoding  2 роки тому +6

      Glad to hear that! It never ends, I learn many new things every day! Sometimes in the process of recording :)

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 2 роки тому +2

      Seriously, if this language had tricks up its sleeves to do a lot of this at compile-time (like Zig), it would've been the most powerful language across the domains.

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 2 роки тому +2

      I mean seriously, so easy to pick up and get started, yet so accessible to dive deep and get lost into the wild wild technicalities.

    • @matthieurochette
      @matthieurochette 2 роки тому +1

      @@VivekYadav-ds8oz You can look into JIT compiling solutions for Python like numba (library) or PyPI (interpreter) for example, it lets the code be compiled at runtime (which slows down the first function call, but generally makes the next ones way faster, catching up to the realm of fully compiled languages)

    • @CHROMIUMHEROmusic
      @CHROMIUMHEROmusic 2 роки тому +1

      @@matthieurochette Yeah numba is awesome!! Relatively simple to use as well

  • @chandramgc
    @chandramgc 2 роки тому

    WoW !!! Metaclass are overwhelming. But they are quite amazing. And really like your efforts in teaching these concepts to us. This is the most interesting UA-cam channel out of all my subscribers #pycharm

  • @FranziskoGomes
    @FranziskoGomes 2 роки тому

    Thank you for your dedicated work, James Murphy. This video proves it once again. #pycharm

    • @mCoding
      @mCoding  2 роки тому +1

      My pleasure!

  • @srijanmukherjee4658
    @srijanmukherjee4658 2 роки тому +10

    and yet again, I feel like my python programming skill has leveled up. #pycharm
    Some more C/C++ content would be great.

  • @calvindang7291
    @calvindang7291 2 роки тому

    This stuff is super cool. That function overloading still looks like black magic after you explained it.
    #pycharm

  • @qsykip
    @qsykip 2 роки тому

    Once again you’ve created a short yet excellent video that I’m going to spend hours replaying and pondering over. Thank you! #pycharm #clion

    • @mCoding
      @mCoding  2 роки тому +1

      My secret plan for increasing audience retention :)

  • @TheGreatAkhillis
    @TheGreatAkhillis 2 роки тому +1

    Well that's the first video that I watch on your channel that left me puzzled yet excited to watch it again #pycharm

    • @mCoding
      @mCoding  2 роки тому

      I'm sure you are in good company, metaclasses are probably the most difficult thing to master in Python. Master metaclasses and you can master the whole language!

  • @zactron1997
    @zactron1997 2 роки тому

    I'd love to see a short followup to this concept using the new Python Match syntax, I don't imagine it drastically changing performance, but I could imagine it allowing for a much cleaner code base.

  • @herogpi1
    @herogpi1 2 роки тому

    Never thought we could define two functions with same name but receive differents parameters, like I was used in C++. That's very nice! #pycharm

  • @yolosaurusrex90
    @yolosaurusrex90 2 роки тому

    been enjoying your videos. i think youtube has a plethora of beginner level content but not enough intermediate to advanced. you're hitting a sweet spot with these videos. #pycharm

  • @jakubzurakowski8815
    @jakubzurakowski8815 2 роки тому

    I probably will never use Metaclasses personally, but it's great to know that they're there and what they do!
    #pycharm #clion

  • @jma42
    @jma42 2 роки тому

    Man, I might actually try making a cool library that can be used in my fav game, metaclasses are so cool

  • @Kuk0san
    @Kuk0san 2 роки тому

    I remember stumbling upon this concept once and wrote some magical shit that even I couldn't parse after the fact, but it worked like a charm so we went with it... If I could track down the code I bet I could understand it better now, thanks for the deep dive! On a side note, abstract base classes are one of my faves, love making use of them #pycharm

  • @philippedias4357
    @philippedias4357 2 роки тому +1

    At least a clear and also deep explanation of metaclass mechanism and some uses. Not sure I will ever use it since changing much class behaviour makes code difficult to maintain. Thanks man. #pycharm which is my favorite IDE for python.

  • @huantian
    @huantian 2 роки тому

    I have no idea what's happening but it works and it's cool!

  • @ErikS-
    @ErikS- Рік тому

    Excellent video. It took me some time to understand it, but it is pretty genius what you do. I saved this video because of it being so valuable...
    I see that your example implementation that allows function overloading, indeed causes a big amount of overhead. Maybe its an idea to raise a PEP for getting a real solution that allows us to overload functions in future version of python. Because honestly, I think it is a very worthwile addition to python.

  • @gregh6586
    @gregh6586 2 роки тому

    James Powell had a great talk at some PyData which included metaclasses though your introduction is much more practical. Nice one! #pycharm

  • @tyto.c
    @tyto.c 2 роки тому

    absolute madness, the great old ones will be impressed #pycharm

  • @ObserverZero
    @ObserverZero 2 роки тому

    Great video on how to be taken out back by your team and shot.

  • @NovaGamma_
    @NovaGamma_ 2 роки тому

    It has been a long time since I was really lost while watching one of your video. Absolutely didn't expected that.
    #pycharm

  • @TheoCJnr
    @TheoCJnr 2 роки тому

    Consistently high quality content. Well done James! #pycharm

  • @yuli3873
    @yuli3873 2 роки тому

    My favourite programming channel

  • @SophieJMore
    @SophieJMore 2 роки тому

    Wow, my mind is literally blown.
    Would be cool to see a video on weakref some time in the future.
    #pycharm

  • @markasiala6355
    @markasiala6355 2 роки тому

    Even if I don't make use of metaclasses anytime soon, the deep dive into the how classes work in the background has been very interesting. #pycharm

  • @svenvancrombrugge9073
    @svenvancrombrugge9073 2 роки тому

    This was pretty mindblowing...

  • @squintingwhale
    @squintingwhale 2 роки тому

    This topic was something I've been wanting to understand better for a while! #pycharm

  • @kpuano
    @kpuano 2 роки тому

    I gave up trying to understand metaclasses before, but with your video I could get a good grasp of it even though I had to watch some parts twice or thrice (so many concepts). Thanks!
    #pycharm

  • @konso1
    @konso1 2 роки тому

    This was a bit more advanced video :D I did understand the concepts but the code scrolled veeeeeeeery quickly. Also, I was too tired to pause and properly read it all :P
    Anyways, thanks so much for making these videos! You're my #1 Python UA-cam video guy!
    #pycharm yes please

  • @Hecticam
    @Hecticam 2 роки тому

    Wonderful video full of examples and use cases to explain this advanced function!
    Looking forward to your next one!
    #pycharm

  • @johanolson1508
    @johanolson1508 2 роки тому

    Love the content from this channel, always educational without the unnecessary babbling. Great vids mate, keep up the good work!
    #pycharm #clion

  • @thatinstant
    @thatinstant 2 роки тому

    Even after watching this video, metaclasses still seem magical. There's no end to what you can do with them. #pycharm

  • @TheAlcalda
    @TheAlcalda 2 роки тому

    #pycharm #clion
    You shed some light onto these Metaclasses - I always avoided those up to now. But now I got some weird ideas, though. I really like the way you get into these deep details of the language.

  • @salmanshah4512
    @salmanshah4512 2 роки тому

    I have used metaclasses before but I never realized you could do this much with them. Very eye opening #clion

  • @jurgen6706
    @jurgen6706 2 роки тому

    I always wondered how these abc classes worked specifically. Thanks!
    #pycharm

    • @mCoding
      @mCoding  2 роки тому

      Glad it was helpful!

  • @sadhlife
    @sadhlife 2 роки тому +1

    "a class defn is actually just syntactic sugar for calling a type constructor"
    There's a tiny caveat here, like being able to pass kwargs to the type definition's bases, which can't be done with `type`. To be able to do that you'd have to use `__build_class__()` instead, so in python3 (i believe starting from py3.1) it's actually sugar for the build class top level function instead.
    It's nothing major though, but I think if you're making an absolute statement it should be correct.

  • @arciomdaniuk
    @arciomdaniuk 2 роки тому

    Great video. Sometimes it's hard to understand such deep diving into python but I'm trying to do my best. Also it's big pleasure for me to see such videos on UA-cam. Thank you!
    #pycharm

  • @cryptosimon9529
    @cryptosimon9529 2 роки тому

    Thank you for all the amazing videos, you rock! #python #pycharm

  • @davidhaggiag
    @davidhaggiag 2 роки тому

    I learn something new with every video you post, thanks.
    #pycharm
    #python

  • @jasperkousen5470
    @jasperkousen5470 2 роки тому

    This video went a little over my head, but I guess that’s how we learn. Thanks for all the videos! #pycharm

  • @hjewkes
    @hjewkes 2 роки тому

    This was absolutely fascinating. I’ve been using ABC meta for ages but didnt know how it worked under the hood #pycharm

  • @Friedrich713
    @Friedrich713 2 роки тому

    The metaclass overload reminded me of monads from functional programming - essentially 'something' that gets treated differently based on its properties. Very neat!
    Oh, and... #pycharm :)

  • @dominicgasperini9553
    @dominicgasperini9553 2 роки тому

    once again, more top notch python content!! would love to hear you share your knowledge of complex topics for other languages too! #clion

  • @TheFlo624
    @TheFlo624 2 роки тому

    I have always wondered what metaclasses are used for. Thanks a lot! #pycharm

  • @MatthiasStuebner
    @MatthiasStuebner 2 роки тому

    Now my mind isn't less bend than before, but I guess when I watched this video 100times it might get better. Thanks for the video.
    #pycharm

  • @samjakbal
    @samjakbal 2 роки тому

    Learned quite a few new things. The effort you put into these videos, is nothing short of amazing! #pycharm

  • @elianangius6465
    @elianangius6465 2 роки тому +1

    Awesome under-the-hood demo implementation of Python’s missing overload OO functionality. #pycharm

  • @dylanthomas7446
    @dylanthomas7446 2 роки тому +1

    Been using abc for awhile, and it's super interesting to know how it operates under the hood. #clion

  • @kaskilelr3
    @kaskilelr3 2 роки тому

    Not gonna lie, my face melted a little bit. Awesome video! Keep it up :D #pycharm

    • @mCoding
      @mCoding  2 роки тому

      Glad you enjoyed it!

  • @sultanapsalamov9309
    @sultanapsalamov9309 2 роки тому

    I'm currently trying to apply the strategy pattern in python, so such a detailed explanation of metaclasses is very useful. Thank you. #pycharm

  • @TARS..
    @TARS.. 2 роки тому

    Heh, I will probably never use this but it's fun seeing what Python can do. Cool vid.

  • @WilliamDye-willdye
    @WilliamDye-willdye 2 роки тому

    In every large code base that I've worked in, a few people have tried out obscure-but-extremely-cool language tricks. Most, but not all, of those cases resulted in long discussions with the people who have to maintain the code, test the code, see the code and want to know about it just out of curiosity, or worst of all, were tracking down a difficult bug and wondered if this obscure code they don't understand could somehow be the culprit. If you take into account the cost of those discussions, it's very rare for the trick to provide a clear net benefit. It's happened, but it's very rare. In a large code base, the highest priority is to make the code readable by others. Please remember that before you use a feature that most others do not know.

    • @mCoding
      @mCoding  2 роки тому +1

      I totally agree, I'm often that person tracking down why a framework needed to change everything to save a few characters. But I do love exploring the limits of what is possible.

  • @tHe0nLyNeXuS
    @tHe0nLyNeXuS 2 роки тому

    Really neat! Just a question: why not use a dict of signature hashes resolve the best_match? I feel like it would be faster than iterating over the list of signatures.

  • @slava6105
    @slava6105 2 роки тому

    Wow! definitely high potential in overload