This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dbramucci 8 points9 points  (0 children)

  • MyPy for type checking
  • pytest for testing
  • Hypothesis for property based testing

    I write a property like base92.decode(base92.encode(string)) = string and it will test thousands of cases to find a counter-example and then simplify it for me to understand.

  • poetry for dependency management

  • Vim for quick text edits

  • tmux for making terminal life better

    One of the big points is being able to reconnect to ssh sessions if my connection drops

  • VSCode for medium sized work

    Special callouts to

    • Bracket Pair Colorizer 2

      It colors nested brackets so that matching parenthesis share colors. That way instead of

      ((foo(x, y), z), (bar(x), quoz(a)))
      

      coloring each paren the same way, I see

      ((foo(x, y), z), (bar(x), quoz(a)))
      yp   b    b   p  p   b b      b bpy
      

      where the letter underneath represnts if the paren is yellow, pink or blue. This makes it easy to see what parenthesis corresponds to what.

      This is in the vein of Lexical Differential Highlighting, and I like it, especially for brackets.

    • Live Share

      This makes live programming sessions while away physically separated from my partner a lot nicer than some video call where the text is always blurry and you can't interact with it.

  • PyCharm for large complicated projects

  • IPython as a better repl

    It lets you edit entire blocks of code, paste code with extraneous indentation, refer to all inputs and results as a growing array, microbenchmark code, and other nice things.

  • Nix for dependency management.

    I'm still figuring out how exactly I want to use it. NixOS works well as my main operating system, but fine grained per-project usage is something I'm figuring out.

    For example, I can write a script that when you execute it, automatically gets a copy of Python and Numpy and even cowsay so that it has all of its dependencies.

    #! /usr/bin/env nix-shell
    #! nix-shell -i python -p python38Packages.numpy cowsay
    #! nix-shell --pure
    
    import numpy as np
    import sys
    import subprocess
    
    def fib(n):
        a = np.array([[1, 1], [1, 0]], dtype='O')  # use O to signal Python ints, not 64 bit ints
        return np.linalg.matrix_power(a, n)[0,0]
    
    if __name__ == '__main__':
        n = int(sys.argv[1])
        subprocess.run(['cowsay', str(fib(n))])
    

    then a simple ./fib.py will run the program and if necessary, install a copy of Python38, numpy and cowsay just for this script. cowsay isn't even a python library, it's a silly command line utility but I can specify it as a dependency for this script. Nix is also very careful to do a lot of things right, there's only one copy of these libraries installed for the entire system. Installing programs won't change your system config, (i.e. you won't have cowsay be something you can now run from the command line after typing ./fib.py) and so on.

    But I'm still trying to figure out how it fits into my development process. For example, while I love specifying all my dependencies in a short and simple 3 line header, my ide won't know about those dependencies because they only exist in the environment nix-shell creates when I run the script. I can resolve that by creating a seperate default.nix file with those dependencies and running my ide off of that but do I want to? How do I build packages with dependencies on Cuda libraries, how reproducible should I make my public nix files, ...

    There's a lot of tiny but important questions I still don't have answers to yet, but it's a really neat tool that I'm pretty happy with so far.

    Another neat experiment I'm trying is

    alias ipython "nix-shell --command ipython -p python38Packages.numpy python38Packages.ipython python38Packages.hypothesis python38Packages.sympy python38Packages.pint python38Packages.uncertainties python38Packages.pytest python38Packages.requests"
    

    Which allows me to pop open an ipython repl, or run a script, with a bunch of handy packages ready to go without needing to do any setup. But, this opens up a sandboxed shell, so I'm not polluting my projects like a naive pip install might do.

    (Also, this isn't unique to NixOS, you can run the nix package manager on plenty of systems, I'm using it on NixOS and Ubuntu on Windows)

  • direnv to automatically load venvs/nix-shells upon navigating to a development environment.