The lines are often blurry because they are quite interlacing and all where purpose build for each other.
> python310.withPackages and python311.withPackages
I think that should be solvable by supplying them the same function.
env = ps: with ps; [ numpy toolz ] python39.withPackages(env) python310.withPackages(env)