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


Groups > comp.lang.python > #36794

Re: Python modules

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!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.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'importing': 0.04; 'subject:Python': 0.05; 'python': 0.09; 'lookup': 0.09; 'subject:modules': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mean,': 0.16; 'module?': 0.16; 'operator.': 0.16; 'program?': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'jan': 0.18; 'module': 0.19; 'trying': 0.21; 'import': 0.21; 'object.': 0.22; '15,': 0.23; 'header:In-Reply-To:1': 0.25; 'creating': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'record': 0.28; "they'll": 0.29; 'probably': 0.29; 'more,': 0.32; 'affects': 0.33; 'picking': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'next': 0.35; 'modules': 0.36; 'test': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'nothing': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'within': 0.64; 'it!': 0.64; 'fact,': 0.69; '2013': 0.84; 'thing,': 0.84; 'careful': 0.91; 'more?': 0.91
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:to :content-type; bh=lTFFspP1cJNv37cSudBhoGPZBgrkfN4YeJn7di15Q1o=; b=tvMfo3NZ22Naqw+djO1z8xrfMDc+WhboH3M1qaI83NOE2g1USCOp6TFVGOPggOwq7W PQZuorIHlohIELoX7PObHFyBcowZe8nM6iz9Uuqh8PRxz3r+suKSnPYD7OeW7kfVNOpq SA6ECqH7R/gYgCcm0l9Zr2trgYw2mbKz2WYPQgvLYBvD8akCMnTvhPYwaCeB2HDSXGzn ZEFhvYVQAcOPd+v6hCCMj4DbhMY83tkmiwUqMBkAW4nmwUzDYRNddGhkRuP+w6Lr9k1Y Q67SG8OCtS5vUwk9yuCS8BuD+kVr/ABzoQspPYjxFJRm+akz7wwoxDGWPXs6zyofyXWj yGpQ==
MIME-Version 1.0
In-Reply-To <kd1667$k6$1@news1.carnet.hr>
References <kd1667$k6$1@news1.carnet.hr>
Date Tue, 15 Jan 2013 02:04:00 +1100
Subject Re: Python modules
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.502.1358175849.2939.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358175849 news.xs4all.nl 6896 [2001:888:2000:d::a6]:38458
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36794

Show key headers only | View raw


On Tue, Jan 15, 2013 at 1:54 AM, zoom <zoom@yahoo.com> wrote:
> Is there any "rules" regarding importing python modules within your own
> module? I mean, how does this affects the performance of the program?
>
> In short, when creating a module, is it worthwhile to be careful and import
> only necessary functions, nothing more?

Nope. When you import a module, a record of it is kept in sys.modules,
so the next time you import it, it's just picking up the same module
object.

> scipy.r_[a] = sound.scipy.r_[a]

They'll actually be the same thing, which you can test with the 'is'
operator. The performance cost of reimporting a module is very low; in
fact, trying to avoid it by adorning all your usage with an extra
dot-level will probably cost you a lot more, since there'll be an
extra lookup every time.

Have at it! :)

ChrisA

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


Thread

Python modules zoom <zoom@yahoo.com> - 2013-01-14 15:54 +0100
  Re: Python modules Dan Sommers <dan@tombstonezero.net> - 2013-01-14 15:01 +0000
    Re: Python modules zoom <zoom@yahoo.com> - 2013-01-14 16:03 +0100
  Re: Python modules Chris Angelico <rosuav@gmail.com> - 2013-01-15 02:04 +1100
    Re: Python modules Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-14 08:27 -0800
    Re: Python modules Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-14 08:27 -0800
      Re: Python modules Grant Edwards <invalid@invalid.invalid> - 2013-01-14 19:48 +0000

csiph-web