Is there an efficient way to use 3rd party packages in PL/Python?
I've found examples of people importing 3rd part packages into PL/Python scripts, but it seems to me that re-importing libraries upon every run of a stored procedure is terribly inefficient.


Using strace, I can see that the files are only actually read the first time an import is done in any given session (there may be exceptions, like if the effective user id changes within a session).  There may be some initialization which is re-done every time the import is run, I don't know how to investigate that.

I don't think you can boost the loading to above the session level.