Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81932

Re: ORM opinion

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'say,': 0.05; 'result,': 0.07; 'socket': 0.07; 'separately': 0.09; 'wrapper': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; 'python': 0.11; 'changes': 0.15; 'feeding': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'imports': 0.16; 'invoking': 0.16; 'layers.': 0.16; 'operation.': 0.16; 'repeatedly.': 0.16; 'specifying': 0.16; 'sqlalchemy': 0.16; 'sqlalchemy,': 0.16; 'sqlite': 0.16; 'subject:ORM': 0.16; 'wrote:': 0.18; 'backend': 0.19; 'server,': 0.19; '(the': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'driver': 0.24; 'module,': 0.24; 'initial': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'changes,': 0.26; 'switch': 0.26; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'ideal': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'feeds': 0.31; 'anyone': 0.31; 'probably': 0.32; 'themselves': 0.32; 'fri,': 0.33; 'minimal': 0.33; 'could': 0.34; "can't": 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'opposed': 0.36; 'done': 0.36; 'doing': 0.36; 'next': 0.36; 'should': 0.36; 'application': 0.37; 'being': 0.38; 'tasks': 0.38; 'little': 0.38; 'anything': 0.39; 'extremely': 0.39; 'either': 0.39; 'remove': 0.60; 'life,': 0.60; 'information,': 0.61; "you're": 0.61; 'first': 0.61; 'back': 0.62; 'times': 0.62; 'real': 0.63; 'more': 0.64; 'within': 0.65; 'benefit': 0.68; 'jobs': 0.68; 'to,': 0.72; 'subject:opinion': 0.84; 'to:none': 0.92; 'directly.': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ntb7kW/nb0XIso7Kl5LH1qHq0PFcQNmWsdrc88QNRnE=; b=S/0FHbWzPZtG4RiTDv0IxvQN5Oycq8ALHvZFxmlspsljNZCt4OGMYEWt4BhHDrQVPt rj/qR/OhFBcg0LD9F5w8k+RM4dyZMSPkNh1CO0RT9mi2cxoCfYjfq2M8EHpirBC8TVJR 1awsnJdjNABft8TgtDQHGcMUl5EZDL3T6y22+QKopCa7rZVaSxZFWOH1dldhxkyWzf2S flpFXzkmvczRmjR2X9QU1FMvl2LExmNyjejlCQ53/Uyz/VVDbdHo1aVUnhASdYuNI0Ep vq9TyOd0nBuqOd2guZ8qrFRjOnUMln6J9PouVYrCQuWXUSksLou51/dl4zLQCD06uTmA Bd5Q==
MIME-Version 1.0
X-Received by 10.42.94.14 with SMTP id z14mr5299282icm.59.1417718206264; Thu, 04 Dec 2014 10:36:46 -0800 (PST)
In-Reply-To <1417716864073.82294@activenetwerx.com>
References <1417716864073.82294@activenetwerx.com>
Date Fri, 5 Dec 2014 05:36:46 +1100
Subject Re: ORM opinion
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16577.1417718215.18130.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417718215 news.xs4all.nl 2892 [2001:888:2000:d::a6]:35864
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81932

Show key headers only | View raw


On Fri, Dec 5, 2014 at 5:14 AM, Joseph L. Casale
<jcasale@activenetwerx.com> wrote:
> Begrudgingly, I need to migrate away from SQLAlchemy onto a
> package that has fast imports and very fast model build times.
>
> I have a less than ideal application that uses Python as a plugin
> interpreter which is not performant in this use case where its
> being invoked freshly several times per operation within the
> application where several operations themselves are queued.
>
> In order to minimize latency, I need to remove anything that
> either takes a noticeable amount of time to import or run. My
> initial backend support is limited to only SQLite.
>
> Anyone have any recos or opinions?

First recommendation: Less layers. Instead of SQLAlchemy, just import
sqlite3 and use it directly. You should be able to switch out "import
sqlite as db" for "import psycopg2 as db" or any other Python DB API
module, and still have most/all of the benefit of the extra layer,
without any extra imports.

Secondly, see if you can keep the Python process running, instead of
separately invoking it for every operation. This will mean some
structural changes, but if you're specifying Python as the plugin
interpreter (as opposed to, say, "execute this program with these
args", which is far more general), you can probably set up a wrapper
script that calls on the user code repeatedly. Perhaps you could have
a multiprocessing.Queue feeding tasks to the subprocess, via a little
parent Python process. If you can't make those kinds of changes to the
application, the next best would be a stubby driver process that feeds
jobs to your real subprocess; the real work might be done by a
Unix/TCP socket server, and the stub connects, feeds it some
information, gets back a result, and disconnects. The stub will have
an extremely minimal set of imports (the bear necessities of life, if
you like), and the real process can import as much as it likes,
because it won't be doing it for every operation.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: ORM opinion Chris Angelico <rosuav@gmail.com> - 2014-12-05 05:36 +1100

csiph-web