• 2 Posts
  • 509 Comments
Joined 1 year ago
cake
Cake day: September 24th, 2023

help-circle







  • The biggest praise i have is, it follows the UNIX philosophy, do one thing and do it well.

    That isn’t a pro on its own, and it’s also a very wooly rule. Uv does one thing and it does it well - Python project management.

    the issue comes down to resources required to maintain a super complex thing

    They seem to be managing fine. I guess having a company back it is enough. But that is also probably my biggest worry about it - what if Astral goes away (which given their apparent lack of business model I suspect they eventually will)? Hopefully uv is popular enough by that point it won’t die.

    I DONT GIVE TWO SHIATS IF ITS FASTER

    It’s literally 10x faster. I’m not sure what kind of person wouldn’t care about that.




  • Yeah the main reason is performance. In some languages if you use a value “linearly” (i.e. there’s only ever one copy) then functional style updates can get transformed to mutable in-place updates under the hood, but usually it’s seen as a performance optimisation, whereas you often want a performance guarantee.

    Koka is kind of an exception, but even there they say:

    Note. FBIP is still active research. In particular we’d like to add ways to add annotations to ensure reuse is taking place.

    From that point of view it’s quite similar to tail recursion. It’s often viewed as an optional optimisation but often you want it to be guaranteed so some languages have a keyword like become to do that.

    Also it’s sometimes easier to write code that uses mutation. It doesn’t always make code icky and hard to debug. I’d say it’s more of a very mild code smell. A code musk, if you like.




  • Easily above average code for Python. I’m going to pick on one method:

    def _set_float_icon(self, is_floating: bool):
                """ set the float icon depending on the status of the parent dock widget """
                if is_floating:
                    self.float_button.setIcon(self.icon_dock)
                else:
                    self.float_button.setIcon(self.icon_float)
    

    First, Python does have ternary expressions so you can

    self.float_button.setIcon(self.icon_dock if is_floating else self.icon_float)
    

    Second, what does this code do?

    foo._set_float_icon(true)
    

    Kind of surprising that it sets the icon to icon_dock right? There are two easy fixes:

    1. Use *, is_floating: bool so you have to name the parameter when you call it.
    2. I’d probably rename it to _update_float_icon() or something.

    Also use Black or Ruff to auto-format your code (it’s pretty well formatted already but those will still improve it and for zero effort).


  • I’ve tried to learn Vim in the past but IMO it is not worth it at all. In a world without multiple cursors… sure, maybe. With multiple cursors? No way. I can can edit just as fast as I’ve seen any Vim user do it, and without having to remember a gazillion mnemonics and deal with the silly modal thing.

    Multiple cursor editing even has some significant advantages over Vim style, e.g. it’s interactive, so you can do your edit gradually and go back if you make a mistake. Rather than having to write a complex command and only finding out it if works at the end. (If you’ve used regex find & replace you’ll understand that problem.)

    I’ll probably get downvoted for this since Vim is kind of a cult, and Vim users get a sense of superiority from it. Kind of like audiophiles - they don’t appreciate it if you tell them their £10k valve amp doesn’t actually sound any better than your £1k digital amp.

    For editing on remote computers I use VSCode remote or Micro for quick tasks.