Python script startup delay in flake dev shell

Just starting out using nixos; I’ve added a flake to a company project:

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";

  outputs = {self, nixpkgs, flake-utils, ... }:
          pkgs = import nixpkgs {
            inherit system;
          python = pkgs.python311.override {
            enableOptimizations = true;
            reproducibleBuild = false;
            self = python;
          # 'build time' deps
          buildInputs = with pkgs; [ pdm python ];
          with pkgs;
            devShells.default = mkShell {
              inherit buildInputs;

Then I can enter the shell with nix develop, install into a virtualenv with pdm install and start work. However, project scripts which start up instantaneously on arch take a few seconds to start running.

e.g. the app registers an entrypoint foo as a command, and running foo --help prints usage: getting to the usage page takes a few seconds.

How do I debug this initial delay? What could be causing it?

On further investigation it’s not a startup delay: it’s just python itself which is slower. Not sure what might be going on here.