... and this line copies the filled map into `self.my_map`. You should be using references, or, if Cython doesn't support those (I seldom use Cython C++ support), pointers. No wonder construction is slow.