Should You ALWAYS Use List Comprehension In Python?

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

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

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

    If performance is important, I'd go with numpy.

  • @nevokrien95
    @nevokrien95 11 месяцев назад +2

    if u are working with large data its a thread/process pool excuter with a map
    if its not parlalizble then save it to memory/push to db inside a for loop
    if its something like an np array or pytorch tensor try and use the package build in operations
    the rest is allways comprehention except if u r working with non python people

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

    well well, that was helpful.

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

    I'm new to programming and using generators with database in case the data comes one day to be large. my question is isn't it always good to go with does the performance matter as big YES like why we even need to consider another approach?

  • @smallbluemachine
    @smallbluemachine 11 месяцев назад +3

    The "Is performance important" diamond should be further up the tree, where the other branch is C++, but now I'm just being rude.

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

      Haha, fair point! Absolutely, it's all about context. While list comprehension in Python can offer great readability and convenience, performance considerations may lead some to explore languages like C++. It's a trade-off between ease of development and raw speed. Although if you go with python you wouldn't want your code freezing unexpectedly!

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

      ya if u need preformance in raw python stuff went horibly wrong.
      we have c# java go for a reason...

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

      There is Libraries in C++ to create module for python too if you need more speed for a particular task it can be quiet useful

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

    Welcome back 🎉