Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39380
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <davea@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'binary': 0.05; 'subject:Question': 0.07; 'thats': 0.07; 'python': 0.09; 'dict': 0.09; 'imports': 0.09; 'lookup': 0.09; 'assume': 0.11; 'advance.': 0.15; 'file,': 0.15; '"import"': 0.16; 'assignment.': 0.16; 'between.': 0.16; 'executed.': 0.16; 'modules,': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'load': 0.19; 'module': 0.19; 'code.': 0.20; 'followed': 0.20; 'import': 0.21; 'visible': 0.22; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'rest': 0.28; 'measure': 0.29; 'probably': 0.29; 'saves': 0.30; 'expect': 0.31; 'up.': 0.31; 'code': 0.31; 'asking': 0.32; 'print': 0.32; 'doubt': 0.33; 'substantial': 0.33; 'to:addr:python-list': 0.33; 'thanks': 0.34; 'skip:l 30': 0.35; 'pm,': 0.35; 'something': 0.35; 'there': 0.35; 'next': 0.35; 'but': 0.36; "i'll": 0.36; 'possible': 0.37; 'does': 0.37; 'level': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'notice': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'easy': 0.60; 'you.': 0.61; 'first': 0.61; 'hours': 0.66; 'further,': 0.71; 'received:74.208': 0.71; 'difference.': 0.84; 'measure.': 0.84; 'received:74.208.4.194': 0.84; 'subject:Import': 0.84; 'dozens': 0.91; 'eli': 0.93 |
| Date | Wed, 20 Feb 2013 16:23:44 -0500 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Import Question |
| References | <c5a35a50-320e-4c1f-a825-c80becd9d20f@googlegroups.com> |
| In-Reply-To | <c5a35a50-320e-4c1f-a825-c80becd9d20f@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:ogk3TC2ytYue+4iX3wis2tFm344rxibfE8DCEN1YdGI h8wLKBthtol7F6sQ1OCpLJhrXfKzBKNrwx8dskHBLL8+JEhhTZ G9C9SKFeDICv5nCkiJB6m15W/fIwRNKdrSYXl31BIcOAdsm98J UxRcSvH3a+jAic4kyqD45Wkzfepx7trnhkEOxxA23PggnHRWBM Z8nPSArgWYB7I4cJAbLFNmhEZvc62ssLLDQkI4MsHQarVtvFRh +VKp9UF7QnmY7NiBQfjmrjbVNn0cwi06AVvdGCg6qYiG32Bwj4 6yUzfbcxKBNK7doV+LOCM5rRL/cQ+ue4ALTn7zKEMP+9zxM5w= = |
| 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.2129.1361395441.2939.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361395441 news.xs4all.nl 6934 [2001:888:2000:d::a6]:35668 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39380 |
Show key headers only | View raw
On 02/20/2013 03:53 PM, eli m wrote: > How long does it take for the program to import something? I am asking this because i have like 7 imports at the beginning of my program and i am thinking thats the reason why it is slow to start up. Thanks in advance. > That would be easy to measure. If you just want a visible indication, put a print before and after those imports, and see how long between. Or use the time module to measure it. Notice that it's possible to write a module that consumes hours during import. All top level code will be executed. So if there's any substantial code there that's not conditional, it'll cost you. For the rest of the message, I'll assume you don't have any time-consuming initialization code. Since there are dozens of imports that happen before your code even begins, I doubt if your own imports make that much difference. Further, some of them are probably already imported, and it's very fast to "import" something already in the cache. About as long as a dict lookup followed by an assignment. When I look at len(list(sys.modules.iterkeys())) in Python 2.7.3, I get the value 243 Some of them are binary modules, which load pretty much instantaneously, and the others are probably precompiled, but I still expect them to swamp the 7 you're doing. BTW, if you measure it, be aware that the first time you import a module, it must be compiled, but then it saves as a .pyc file, and the next time it'll be much quicker. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Import Question eli m <techgeek201@gmail.com> - 2013-02-20 12:53 -0800 Re: Import Question Matteo Boscolo <matteo.boscolo@boscolini.eu> - 2013-02-20 22:01 +0100 Re: Import Question Michael Herman <hermanmu@gmail.com> - 2013-02-20 13:03 -0800 Re: Import Question Dave Angel <davea@davea.name> - 2013-02-20 16:23 -0500
csiph-web