Caching Python modules - Mailing list pgsql-hackers

From PostgreSQL - Hans-Jürgen Schönig
Subject Caching Python modules
Date
Msg-id 682AACCD-6E75-4A1F-9A19-16FDE8BAC922@cybertec.at
Whole thread Raw
Responses Re: Caching Python modules
List pgsql-hackers
hello …

i have just fallen over a nasty problem (maybe missing feature) with PL/Pythonu …
consider:

-- add a document to the corpus
CREATE OR REPLACE FUNCTION textprocess.add_to_corpus(lang text, t text) RETURNS float4 AS $$
       from SecondCorpus import SecondCorpus       from SecondDocument import SecondDocument

i am doing some intense text mining here.
the problem is: is it possible to cache those imported modules from function to function call.
GD works nicely for variables but can this actually be done with imported modules as well?
the import takes around 95% of the total time so it is definitely something which should go away somehow.
i have checked the docs but i am not more clever now.
many thanks,
    hans

--
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Online base backup from the hot-standby
Next
From: Jan Urbański
Date:
Subject: Re: Caching Python modules