Hello,
I'm looking at a small app which would need a very quick
startup time for the Python interpreter. It doesn't do much (copying
and caching of files, no GUI) but I need the Python interpreter to start
up very quickly (<1 second on a Windows box). Is there a way to have a
'stripped' down Python interpreter which can start up very quickly on a
windows box. Once thing I was thinking of was to use PyExe to make a
quick startup (does it compile down to C code, therefore not using the
Python interpreter at runtime?). Is this a possible solution?
I observe that the second time I start python it starts up quicker
but I'm assuming that this is dependent on the environment and can't be
relied upon (or something like that).
Thanks, in advance for your help.
Cheers,
Neil
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : be**@cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com 16 5778
Neil Benn wrote: I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python interpreter to start up very quickly (<1 second on a Windows box).
What kind of machine do you have?
On mine, Python starts up in about 0.06 seconds...
This primitive test shows these results on a Windows XP machine
(it won't work with Windows 98 as it can't chain commands on the
command line like that, but you could but it in a batch file).
c:\>echo. | time & python -c "import time; print time.time()"
The current time is: 8:59:59.67
Enter the new time:
1092315599.73
This is a fairly fast machine (Athlon 2500+) but I really
doubt slower machines would take much longer than 1 second
unless they are *really* old.
-Peter
Peter Hansen wrote .... Neil Benn wrote:
I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python interpreter to start up very quickly (<1 second on a Windows box).
What kind of machine do you have?
On mine, Python starts up in about 0.06 seconds...
This primitive test shows these results on a Windows XP machine (it won't work with Windows 98 as it can't chain commands on the command line like that, but you could but it in a batch file).
c:\>echo. | time & python -c "import time; print time.time()" The current time is: 8:59:59.67 Enter the new time: 1092315599.73
This is a fairly fast machine (Athlon 2500+) but I really doubt slower machines would take much longer than 1 second unless they are *really* old.
-Peter
This variation on Peter's timing
is from a 5-year-old 250 MHz Compaq
running Linux/Debian ...
sk@cpq1 : ~/c $ ./gtod & python -c "import time ;
print ' Python ....' , time.time()"
[1] 1677
Number of seconds ......... 1092323003
Number of microseconds .... 194433
Time zone ............... .. 420
Daylight savings time ..... 0
Python .... 1092323003.36
--
Cousin Stanley
Human Being
Phoenix, Arizona
On Thu, 12 Aug 2004, Neil Benn wrote: Is there a way to have a 'stripped' down Python interpreter which can start up very quickly on a windows box.
Two things you can do are:
1) Run Python as "python -S". Normally, Python does an 'import site'
before running other code. Starting with 2.3, this does lots of expensive
localization goo, etc.; my guess is your script doesn't need it to execute
correctly, if it doesn't use any i18n functions.
2) Pre-compile the script. Normally, Python generates .pyc files for
imported modules so it doesn't have to re-parse the source code, but it
won't do this for a script specified on the command line. You can force
it to compile your script by importing the script in the interactive
interpreter, but this will also run your script (possibly not desirable).
You can compile the script without running it by using the py_compile
module:
python -c 'import py_compile; py_compile.comp ile("my_script. py")'
You can then run the compiled version using 'python my_script.pyc'
('python my_script.py' will ignore the compiled version).
Once thing I was thinking of was to use PyExe to make a quick startup (does it compile down to C code, therefore not using the Python interpreter at runtime?). Is this a possible solution?
Nope. py2exe just embeds the Python interpreter in the .exe. If
anything, startup would be slower, since py2exe also places all required
modules in a ZIP archive.
Neil Benn <be**@cenix-bioscience.com> wrote in message news:<ma******* *************** *************** *@python.org>.. . Hello,
I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python interpreter to start up very quickly (<1 second on a Windows box). Is there a way to have a 'stripped' down Python interpreter which can start up very quickly on a windows box.
This has been discussed before, there's definitely something "odd"
about the Windows startup time in comparison to the UNIX "instant"
startup.
Once thing I was thinking of was to use PyExe to make a quick startup (does it compile down to C code, therefore not using the Python interpreter at runtime?). Is this a possible solution?
Nope, no compiling to C/machine code, just bytecode, and the
interpreter is a DLL.
I observe that the second time I start python it starts up quicker but I'm assuming that this is dependent on the environment and can't be relied upon (or something like that).
Yeah, I think that's something to do with Windows caching.
I keep saying, we need a Python compiler.....
simo wrote: Neil Benn <be**@cenix-bioscience.com> wrote in message news:<ma******* *************** *************** *@python.org>.. . I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python interpreter to start up very quickly (<1 second on a Windows box). Is there a way to have a 'stripped' down Python interpreter which can start up very quickly on a windows box.
This has been discussed before, there's definitely something "odd" about the Windows startup time in comparison to the UNIX "instant" startup.
Discussed, but not to a satisfactory conclusion I think.
The fact that some of us have near instantaneous startup times,
consistently (whether immediately after reboot or not) on Windows,
even with older machines, suggests strongly that those who do
not have something *wrong* with their system.
I don't recall the OP in the last thread that discussed this
ever coming back to report on exactly what OS and CPU etc.
he was using, and whether network issues might be involved,
etc, so until someone can prove otherwise, I think it's
safe to assume that anyone with a slow startup on Windows
has a misconfiguratio n or is doing something wrong.
-Peter
In article <Pi************ *************** **********@ccc8 .wpi.edu>,
Christopher T King <sq******@WPI.E DU> wrote: 2) Pre-compile the script. Normally, Python generates .pyc files for imported modules so it doesn't have to re-parse the source code, but it won't do this for a script specified on the command line. You can force it to compile your script by importing the script in the interactive interpreter, but this will also run your script (possibly not desirable). You can compile the script without running it by using the py_compile module:
python -c 'import py_compile; py_compile.comp ile("my_script. py")'
You can then run the compiled version using 'python my_script.pyc' ('python my_script.py' will ignore the compiled version).
That's a Bad Idea. Better Idea: move the code into a separate module
and put the code into a function. Then change this script into a very
short driver that imports/calls the function.
--
Aahz (aa**@pythoncra ft.com) <*> http://www.pythoncraft.com/
"To me vi is Zen. To use vi is to practice zen. Every command is a
koan. Profound to the user, unintelligible to the uninitiated. You
discover truth everytime you use it." --*****@lion.aust in.ibm.com
"Aahz" <aa**@pythoncra ft.com> wrote in message
news:cf******** **@panix1.panix .com... In article <Pi************ *************** **********@ccc8 .wpi.edu>, Christopher T King <sq******@WPI.E DU> wrote:
*snip* You can then run the compiled version using 'python my_script.pyc' ('python my_script.py' will ignore the compiled version).
That's a Bad Idea.
*snip*
Hello,
I'm pretty new to Python and programming in general but I have done this
before. Why is this a bad idea?
Also (maybe not the right place to ask, but...), I was thinking of driving
up to BayPiggies because I am interested in tonights discussion but it's a
long drive and I'm afraid it would be way over my head. Do you get a lot of
newbie participants? Thanks for your input.
Louis
| ....
| This primitive test shows these results on a Windows XP machine
| ( it won't work with Windows 98
| as it can't chain commands
| on the command line like that,
| but you could but it in a batch file ).
| ....
I stuck it in a .bat file under Win98_SE
on the same dual-boot machine that I used
for the Linux/Debian test ....
Win98_SE .... Python 2.3 Enthought Edition
Debian ...... Python 2.3.4
< K:\C\MinGWStudi o\Samples\Time\ Debug >
Thu 08-12-2004 18:49:03.23
py_time
Number of Seconds Since January 1, 1970 ....
1092361745
1092361746.75
The Linux/Debian number is only slightly quicker
with Python 2.3.4 and probably given a larger number
of tests, there might be no significant difference ....
Number of seconds ......... 1092323003
Python ............... ..... 1092323003.36
So, for an old 250 MHz machine, I seem to be loading
Python OK for both Win98 & Linux ....
--
Cousin Stanley
Human Being
Phoenix, Arizona
Peter Hansen wrote: <snip> I don't recall the OP in the last thread that discussed this ever coming back to report on exactly what OS and CPU etc. he was using, and whether network issues might be involved, etc, so until someone can prove otherwise, I think it's safe to assume that anyone with a slow startup on Windows has a misconfiguratio n or is doing something wrong.
<snip>
Hello,
Hi, I'm the OP, my box is :
WinXP Pro
2.4Gz Processor
256M RAM
Python2.3
As I said the first load takes 5 seconds and the consecutive loads
take fractions of a second - my assumption is that Windows is caching
something which is not suitable for my needs as it is not predictable
enough. There is no network issues involved in this, everything is
running off the local hard drive. I've just this moment run python
after the box having done some work and being asleep overnight and the
startup time was about 2 seconds. I may be doing something wrong but
the only configuration stuff I've done is to add into my environment
variables :
PYTHON_HOME=c:\ program files\python23
PATH=%PATH%;PYT HON_HOME
This is simply to allow me to switch between different python
directories when I start to install different versions (I do the same
with the JVM). If python can't start up quick on windows, that's fine,
if I've got something miscofigured which can be fixed, that's fine too -
I just need to know if there is a 'quick start up' mode but if there
isn't then that's also fine. It's just info I need to design what will
be a very simple app.
Thanks, for your help.
Cheers,
Neil
--
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : be**@cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kim Gijung |
last post by:
Hi all,
I'm wondering how the apache server and php interepreter handles
request.
If one request comes to apache server what is next procedure?
if apache server passes the request to php interepreter and php
interepreter handles?
what if 10 requests comes at same time? apache server forks 10 php
interepreter?
or php interepreter makes 10 threads for each request?
|
by: morris.slutsky |
last post by:
So every now and then I like to mess around with hobby projects - I
often end up trying to write an OpenGL video game. My last attempt
aborted due to the difficulty of automating game elements and creating
a good level editor - I basically needed a scripting language to
control the C modules of the game and, after a half-assed attempt or
two to make my own, I just gave up. So naturally this seems like a job
for Python. Embedding Python...
|
by: castironpi |
last post by:
I'm curious about some of the details of the internals of the Python
interpreter:
I understand C from a hardware perspective.
x= y+ 1;
Move value from place y into a register
Add 1 to the value in the register
Move the addition's result to place x
|
by: Pedro Borges |
last post by:
Hi guys,
Is there a way to improve the interpreter startup speed?
In my machine (cold startup) python takes 0.330 ms and ruby takes
0.047 ms, after cold boot python takes 0.019 ms and ruby 0.005 ms to
start.
|
by: rcreddych |
last post by:
I am getting the following error while deploying a simple Java Stored Procedure. I am using db2 8 and using the IBM Data Studio. I am new to DB2. Your help will be apreciated.
CHETR.PROCEDURE1 - Deploy started.
CHETR.PROCEDURE1 - Created temporary working directory C:\PROJECTS\IBM\TEST3\workspace\.metadata\.plugins\com.ibm.datatools.db2.routines.deploy.ui\bld1226688205679.
C:\Program Files\IBM\DSADM1.2\jdk\bin\javac -classpath...
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |