Is Your Python Code Unsafe? GIL’s Hidden Secret

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024

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

  • @TheArtikae
    @TheArtikae 11 หลายเดือนก่อน +38

    Answer for your crimes: Why have you created an anime OC for the GIL?

  • @VeryaliveWoW
    @VeryaliveWoW ปีที่แล้ว +21

    The GIL protects pythons internal interpreter state, that does not mean that you cannot introduce race conditions of your own as in this example. The job of the GIL is not to ensure that data structures that you choose to use are atomically locked

    • @t0prar
      @t0prar ปีที่แล้ว +6

      ☝ this. Copying a value, sleeping and then applying it is a logical error, not a data race. No language will protect you from that.
      Also clickbait title. If you're talking about a vulnerability. Please refer to a (possible) CVE. >.

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว +3

      I see a lot of you are mentioning the clickbait title, I wanted to address this, and apologize. I'm still trying to find a balance when it comes to video packaging, and my titles and thumbnails often change frequently within the first 24 hours after publish. I'll work toward packaging that better represents the contents of the video going forward.
      I'm sorry it was viewed this way 😔. I take responsibility, and it won't happen again going forward.

    • @VeryaliveWoW
      @VeryaliveWoW ปีที่แล้ว +4

      @@DanielBoctor The title may be a little sensational but hey, that's youtube for you. I think the video is well produced and covers an interesting topic, I just wanted to add some context :)

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว +1

      @@VeryaliveWoW ayyyy thank you for the kind words, I appreciate it!

    • @almightyhydra
      @almightyhydra 9 หลายเดือนก่อน +1

      ​@@DanielBoctor I've noticed a number of creators do this and really don't understand the point. Is it simply to bait people who have already watched the video into clicking it again as they think it's something else? Surely that's likely to lead to viewers getting annoyed, ultimately resulting in less viewership?

  • @naumbtothepaine0
    @naumbtothepaine0 10 หลายเดือนก่อน +4

    Never know stuff that I thought unrelevant in my Operating System course could have so much potential impact on coding lol

  • @camelotenglishtuition6394
    @camelotenglishtuition6394 10 หลายเดือนก่อน +3

    Amazing explanation

  • @kolaysgames
    @kolaysgames 8 หลายเดือนก่อน

    the 5ms constant is all you need to add some wildly difficult heisenbugs to your code.

  • @ally6438
    @ally6438 11 หลายเดือนก่อน +3

    Fascinating thank you

    • @DanielBoctor
      @DanielBoctor  11 หลายเดือนก่อน +1

      Glad you liked it 😊

  • @TheControlMastr
    @TheControlMastr ปีที่แล้ว +2

    1:47 what you did here was so amazing 😭 He just made everything a for loop function in .5 🎉

  • @dracula5752
    @dracula5752 8 หลายเดือนก่อน +1

    great video i mean first mistake trying to use multi threading in python if you need speed just use go lmao.

  • @oxi2118
    @oxi2118 ปีที่แล้ว +4

    High quality vid, thanks a lot for this!

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว

      I'm glad you enjoyed, thank you!

  • @CielMC
    @CielMC 10 หลายเดือนก่อน +1

    Great video, but where did you get the Python waifu image from?

    • @DanielBoctor
      @DanielBoctor  10 หลายเดือนก่อน +2

      I generated it with AI lol

  • @denysholovatyi3149
    @denysholovatyi3149 6 หลายเดือนก่อน

    background music too loud

  • @ionrael
    @ionrael ปีที่แล้ว

    I am studying this at operating system subject of my career and its very interesting. A single process can have multiple threads and the data can be accesed between threads and thats why without GIL your code can have different results. Multithreading itself is a threat to security due the way it works (if not handled properly). Thats why web browser can't be multithreaded, because that could mean a tab runing one page could acces information on another tab. Thats why browsers use multiproccesing instead, F.E. Firefox creates one proccess per tab (and that is also why JavaScript is singleThread only, not because they are lazy to implement multithreading but because its more secure).
    Processes are managed by the OS, they can also share information and they are organized in a hierarchy tree (father processes could have sons and so on)
    But I'm not sure if the OS give each procces its own thread or they are executed in other way.

  • @tiwongemhango955
    @tiwongemhango955 ปีที่แล้ว

    Love your videos. Hope to see you with a mil+ subscribers one day 🙏🏾

  • @igorgiuseppe1862
    @igorgiuseppe1862 ปีที่แล้ว

    great video.
    i clicked because of the waifu, but still didnt figure out why she is there lol

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว +1

      LOOOOOOOL it's just a play on words because GIL is also a girl's name

  • @Proprogrammer001
    @Proprogrammer001 ปีที่แล้ว +2

    Can I use AI to make a 24 hour version of this video but replace everything you're saying with some gibberish because its so soothing but packed with crazy good info at the same time.
    I want this to run in the bg while I work but not get tired of absorbing info / info saturated.
    Even the bg music choice was so good.
    Don't appreciate the clickbait tho :/

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว +1

      I appreciate the comment, it means a lot
      In regards to the clickbait, I apologize 😔I'm still trying to find a balance when it comes to video packaging, and my titles and thumbnails often change frequently within the first 24 hours after publish. I'll work toward packaging that better represents the contents of the video going forward.

  • @ivanleonelvera7540
    @ivanleonelvera7540 7 หลายเดือนก่อน

    If Gil ends up doing nothing and the only thing that prevents race conditions is the operating system, why Gil even exist? Let's let all the task to the os and the code can run 4x faster.

  • @0maxekinge0
    @0maxekinge0 ปีที่แล้ว

    Rewrite it in rust 🎉

  • @HHHjb_
    @HHHjb_ 10 หลายเดือนก่อน

    got an ad literally every minute(note this is more than the default rate by about 3 to 4 times) hence Im not watching this despite how interesting it is

  • @aurkom
    @aurkom ปีที่แล้ว

    What did you use to create that blue haired character tho at 0:18?

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว +2

      I used an AI image model - specifically live3d.io

    • @aurkom
      @aurkom ปีที่แล้ว

      Oh thank you, I am quite curious to know the prompt you used. @@DanielBoctor

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว +2

      @@aurkom LOOOOOOL I don't remember the exact one, but it was along the lines of 'blue hair, yellow shirt, blue jacket.......' It was nothing crazy.

    • @aurkom
      @aurkom ปีที่แล้ว

      I see, thank you! What I found interesting was the python logo in the character. I was surprised thinking that even that logo came up in the generation. I am assuming it was edited later. @@DanielBoctor

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว +3

      @@aurkom oh yeah - I placed that python logo there after the fact, should have mentioned that lol

  • @bitpilot79
    @bitpilot79 ปีที่แล้ว +5

    Your voice is too low compared to the background music volume. Sometimes it's hard to understand what are you talking.

    • @DanielBoctor
      @DanielBoctor  ปีที่แล้ว

      Thank you for pointing this out, I appreciate it. I'll lower it going forward 😊

  • @raiden7821
    @raiden7821 ปีที่แล้ว

    I am high now

  • @Zsombro42
    @Zsombro42 ปีที่แล้ว

    Nice video, tho that multiprocessing code is the textbook example of what not to do when you use multiprocessing. I also find your pronunciation of GIL horrific :(

  • @cancername
    @cancername ปีที่แล้ว

    "In fact, it is a mathematical certainty that my CPU will never perform more than 4 operations at once."
    That's true, but only if you ignore instruction-level parallelism and SIMD.