Sourcery is an INCREDIBLE AI refactoring tool for Python

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024
  • I've covered a lot of QA tools on this channel, but nothing AI powered -- until now! Sourcery is incredibly powerful, so much so in fact, it will almost definitely make you feel like an idiot when using it.
    -
    If you enjoy my content, consider supporting me on Patreon or becoming a member!
    patreon.carber...
    join.carberra.xyz
    If you need help with anything, feel free to join the Discord server:
    discord.carber...
    I get a lot of people asking, so here's my Visual Studio Code setup!
    • My Visual Studio Code ...
    -
    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

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

  • @gardnmi
    @gardnmi Год назад +16

    I now have sourcery correcting copilot suggestions on my editor. Let the AI wars begin!

  • @ChristophBackhaus
    @ChristophBackhaus Месяц назад +1

    I believe that what we are currently doing with code generation is wrong. AI should really be used to refactor software that already exist. So instead of using package managers we should refactor packages into our projects removing all dependencies.

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

    Set lookup is using a hash table which provides O(1) time , finding an element in a tulle or list requires comparing iteratively through all elements and is O(n). So Sets will be much much faster still, for a growing number of elements.
    However make sure building the set doesn’t take up much of the time …. (If the elements have a difficult to compute hash value)

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

    if check function refactored didn't use bool(x and y), then check(True, 0) would return 0, and check(0, whatever) would return 0. bool makes it either True or False

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

    Really nice tutorial - started using Sourcery a little while ago and it's really really good :) Out of curiosity, can you share your benchmark scripts ?? Interested to know how people are setting up these benchmarks - are you using the timeit like in one of your other tuts ??

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

      I don't know if I have the exact scripts anymore, but yeah they're just using timeit. I made a video on it, but that's probably the video you're eluding to 😆

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

      @@Carberra ah yeah, in the video you actually opened one 🤣 good content mate, definitely going to be checking out more of your work :)

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

    I wouldn't count this as "refactoring" tool, more of a lint/checker. Was hoping this was an actual refactoring tool. Nice overview of tool though.

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

      Thanks! To be fair, I've seen it refactor entire functions before, these were just smaller examples. "Refactoring tool" is how Sourcery themselves define it as anyways.

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

    they are removing the free plan I think, got email, so now its getting more updates and need to buy the license

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

      thats right. I think at this point, I'll just stick with copilot.

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

      they not removed the free plan@@MrKrizzer

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

    Nice tool, even though I don't legit so much from an AI that change my code, I mean, sometimes I ask to ChatGPT that refactor certain method and If I copy paste the result, it may have bugs or it change a bit my code. So I prefer to go line by line.

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

    Did you just say that writing code which is a bit faster is more important than writing readable code? I mean, from my experience, they are lesser the cases where you would rather speed over readability. Whoever is writing Python code should know that. If you want a more performance runtime, then you should be considering using C, C++ or any other alternatives to this low level languages. And don't get me wrong, I do try my best to write efficient code, but I also try to maintain a balance.

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

      I never said anything about sacrificing readability for the sake of speed. I agree with you regarding a balance between the two, but there's no harm in trying to optimise code. Cleaner Python code tends to run faster anyways.

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

    I think this is a great tool, but where is this taking the rules from? I mean, in the Demo class, I'd prefer to have the original class in my code over the suggested one. It's more readable. By the way, you said that you almost see no difference between using a tuple and a set while checking to see if an element in there; try adding a more items... try with 1000 or 10,000 and you see how it drops performance when using the tuple. Because it has to scan almost the whole list, which compared to the set it will follow a linear pattern O ( N )

    • @Carberra
      @Carberra  Год назад +6

      That's...not at all what I said.
      7:18 - "You can see that sets are faster when the element does exist, and they are twice as fast when the element doesn't."