HYBRID callables in Python?! - Jankfest

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ค. 2024
  • Welcome to the first in a series I'm calling "Jankfest"! This series will largely explore some very weird thing you probably shouldn't recreate. In this video, hybrid sync/async functions!
    The code: gist.github.com/parafoxia/15c...
    I've done it as a Gist as I couldn't be bothered setting up a fully fledged PR for it -- if you want to send me any fixes, I guess email me the diff (proper Linux kernel style!).
    -
    If you enjoy my content, consider supporting me on Patreon or becoming a member!
    • Patreon: / carberra
    • Membership: / @carberra
    Follow me elsewhere for even more Carberra!
    • Discord: / discord
    • Instagram: / carberratutorials
    I get a lot of people asking, so here's my setup!
    • Visual Studio Code: • My Visual Studio Code ...
    • Terminal: • Make your terminal loo...
    -
    If you have any questions, don't hesitate to ask in the comments! I'll try and answer as soon as I can, providing someone else hasn't already done so.
    #python #coding #howto

ความคิดเห็น • 10

  • @crysiank
    @crysiank 22 วันที่ผ่านมา

    This would be really cool if you get it to work.
    Would isawaitable and isiscoroutinefunction a good way to check if it's async?
    I thought you could only do reflection in python and get variable names and types.
    I didn't know you could get tokens of the actual code itself.
    How are you enforcing static typing in lists when using generics?

    • @Carberra
      @Carberra  22 วันที่ผ่านมา

      I originally tried to do it using iscoroutine but apparently that doesn't do anything for type checking, so I guess it can only work it out at runtime. But yeah, you can get literally anything out of it. Generics rely on other parts of the context to figure out the correct types, I think if there's not enough context it'll error.

  • @gerokatseros
    @gerokatseros 22 วันที่ผ่านมา

    what tool did you use to make the flowcharts? looks very interesting, so your approach!!

    • @Carberra
      @Carberra  22 วันที่ผ่านมา

      It's called Eraser (with an S! -- eraser.io). Pretty nice tool actually.

  • @DuncanBooth
    @DuncanBooth 20 วันที่ผ่านมา

    I can't see how you could ever cover all the cases magically. I've written code that built up a list of futures to call asyncio.gather at the end so how could you ever tell the context at runtime? Much better I think just to depend on the type system to ensure you don't forget the 'await' when it's needed.

  • @alimconde7629
    @alimconde7629 22 วันที่ผ่านมา

    What tool is this that you're using?

    • @Carberra
      @Carberra  22 วันที่ผ่านมา +1

      Ignore my previous comment, just realised you probably mean the flowcharts cos someone else has just asked about it lmao. It's Eraser (eraser.io).

  • @kaizen8808
    @kaizen8808 22 วันที่ผ่านมา +2

    Sorry, could not watch it till the end. You are scrolling way to fast when explaining. You should stop for at least a second or so after scrolling.

    • @Carberra
      @Carberra  22 วันที่ผ่านมา +1

      I'll keep that in mind for next time I do a video like this! Thanks for the feedback.

    • @birdie123
      @birdie123 22 วันที่ผ่านมา

      @@Carberra A split screen might be good instead of the scrolling...