[Pythonmac-SIG] Re: MacPython 2.2.2 final candidate

Chris Barker Chris.Barker@noaa.gov
Fri, 1 Nov 2002 16:47:36 -0800


--Apple-Mail-2--91202036
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed


On Friday, November 1, 2002, at 07:00 AM, Jack Jansen wrote:

>
> On donderdag, okt 31, 2002, at 19:04 Europe/Amsterdam, Neil Mayhew 
> wrote:
>
>> If I start up with 'Trace import statements' and 'Also show failed 
>> attempts'
>> checked, there is a very noticeable pause after 'import __future__ #
>> precompiled from ... Python 2.2.2:Lib:__future__.pyc' and before '# 
>> trying
>> .. Python 2.2.2:sitecustomize.carbon.slb'

I get exactly the same results.

> Some things to try:
> - Run Python with site disabled, then manually import __future__, and 
> see how slow that is.

essentially instant

> - Run Python site site disabled, then manually import types (which is 
> what imports __future__).

also instant

> I don't think either of these are to blame, but they're easy to test 
> so do that first.

apparently not.

> Next, if these both run fast enough, rig up site.py with print 
> statements and see where the delay occurs.

OK, I added a bunch of print and timing statements to site.py and got 
this:

starting site.py
elapsed time is: 0.00 seconds
defining makepath
elapsed time is: 0.01 seconds
running sys.modules loop
elapsed time is: 0.01 seconds
starting absolute path routine
elapsed time is: 0.00 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 2.2.2:
elapsed time is: 0.01 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Mac:Lib
elapsed time is: 0.82 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Mac:Lib:lib-compat
elapsed time is: 0.21 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Mac:Lib:lib-scriptpackages
elapsed time is: 0.00 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Lib:lib-dynload
elapsed time is: 0.11 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Lib
elapsed time is: 10.88 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Extensions:img:Mac
elapsed time is: 0.11 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Extensions:img:Lib
elapsed time is: 0.01 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Extensions:Imaging
elapsed time is: 0.01 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Lib:lib-tk
elapsed time is: 0.11 seconds
Inside absolute path loop, dir = Macintosh HD:Applications:Python 
2.2.2:Lib:site-packages
elapsed time is: 0.01 seconds
running " append ./build...
elapsed time is: 0.00 seconds
running prefixes...
elapsed time is: 2.54 seconds
defining quit and exit
elapsed time is: 0.00 seconds
printing credits
elapsed time is: 0.01 seconds
defining new help
elapsed time is: 0.00 seconds
setting string encoding
elapsed time is: 0.00 seconds
trying to import sitecustomize
elapsed time is: 0.11 seconds
removing sys.setdefaultencoding()
elapsed time is: 0.00 seconds


so, it looks like it is taking a long time to process: Macintosh 
HD:Applications:Python 2.2.2:Lib in the absolute path routine

It also takes a while to run  the prefixes code as well.

I've enclosed the altered site.py file, if anyone else want to try it. 
I don't have any more time to look at this for the next week, but maybe 
jack (or someone) will get an idea from my results.

-Chris


--Apple-Mail-2--91202036
Content-Disposition: attachment;
	filename=site.py
Content-Transfer-Encoding: quoted-printable
Content-Type: application/text;
	x-mac-creator=522A6368;
	x-unix-mode=0644;
	x-mac-type=54455854;
	name="site.py"

"""Append=20module=20search=20paths=20for=20third-party=20packages=20to=20=
sys.path.=0D=0D=
****************************************************************=0D*=20=
This=20module=20is=20automatically=20imported=20during=20initialization.=20=
*=0D****************************************************************=0D=0D=
In=20earlier=20versions=20of=20Python=20(up=20to=201.5a3),=20scripts=20=
or=20modules=20that=0Dneeded=20to=20use=20site-specific=20modules=20=
would=20place=20``import=20site''=0Dsomewhere=20near=20the=20top=20of=20=
their=20code.=20=20Because=20of=20the=20automatic=0Dimport,=20this=20is=20=
no=20longer=20necessary=20(but=20code=20that=20does=20it=20still=0D=
works).=0D=0DThis=20will=20append=20site-specific=20paths=20to=20to=20=
the=20module=20search=20path.=20=20On=0DUnix,=20it=20starts=20with=20=
sys.prefix=20and=20sys.exec_prefix=20(if=20different)=20and=0Dappends=20=
lib/python<version>/site-packages=20as=20well=20as=20lib/site-python.=0D=
On=20other=20platforms=20(mainly=20Mac=20and=20Windows),=20it=20uses=20=
just=20sys.prefix=0D(and=20sys.exec_prefix,=20if=20different,=20but=20=
this=20is=20unlikely).=20=20The=0Dresulting=20directories,=20if=20they=20=
exist,=20are=20appended=20to=20sys.path,=20and=0Dalso=20inspected=20for=20=
path=20configuration=20files.=0D=0DA=20path=20configuration=20file=20is=20=
a=20file=20whose=20name=20has=20the=20form=0D<package>.pth;=20its=20=
contents=20are=20additional=20directories=20(one=20per=20line)=0Dto=20be=20=
added=20to=20sys.path.=20=20Non-existing=20directories=20(or=0D=
non-directories)=20are=20never=20added=20to=20sys.path;=20no=20directory=20=
is=20added=20to=0Dsys.path=20more=20than=20once.=20=20Blank=20lines=20=
and=20lines=20beginning=20with=0D'#'=20are=20skipped.=20Lines=20starting=20=
with=20'import'=20are=20executed.=0D=0DFor=20example,=20suppose=20=
sys.prefix=20and=20sys.exec_prefix=20are=20set=20to=0D/usr/local=20and=20=
there=20is=20a=20directory=20/usr/local/lib/python1.5/site-packages=0D=
with=20three=20subdirectories,=20foo,=20bar=20and=20spam,=20and=20two=20=
path=0Dconfiguration=20files,=20foo.pth=20and=20bar.pth.=20=20Assume=20=
foo.pth=20contains=20the=0Dfollowing:=0D=0D=20=20#=20foo=20package=20=
configuration=0D=20=20foo=0D=20=20bar=0D=20=20bletch=0D=0Dand=20bar.pth=20=
contains:=0D=0D=20=20#=20bar=20package=20configuration=0D=20=20bar=0D=0D=
Then=20the=20following=20directories=20are=20added=20to=20sys.path,=20in=20=
this=20order:=0D=0D=20=20/usr/local/lib/python1.5/site-packages/bar=0D=20=
=20/usr/local/lib/python1.5/site-packages/foo=0D=0DNote=20that=20bletch=20=
is=20omitted=20because=20it=20doesn't=20exist;=20bar=20precedes=20foo=0D=
because=20bar.pth=20comes=20alphabetically=20before=20foo.pth;=20and=20=
spam=20is=0Domitted=20because=20it=20is=20not=20mentioned=20in=20either=20=
path=20configuration=20file.=0D=0DAfter=20these=20path=20manipulations,=20=
an=20attempt=20is=20made=20to=20import=20a=20module=0Dnamed=20=
sitecustomize,=20which=20can=20perform=20arbitrary=20additional=0D=
site-specific=20customizations.=20=20If=20this=20import=20fails=20with=20=
an=0DImportError=20exception,=20it=20is=20silently=20ignored.=0D=0D"""=0D=
=0Dimport=20sys,=20os,=20time=0D=0Dstart=20=3D=20time.time()=0Dprint=20=
"starting=20site.py"=0D=0D=0Dprint=20"elapsed=20time=20is:=20%.2f=20=
seconds"%(time.time()-start,=20)=0Dprint=20"defining=20makepath"=0D=0D=
def=20makepath(*paths):=0D=20=20=20=20dir=20=3D=20=
os.path.abspath(os.path.join(*paths))=0D=20=20=20=20return=20dir,=20=
os.path.normcase(dir)=0D=0Dprint=20"elapsed=20time=20is:=20%.2f=20=
seconds"%(time.time()-start,=20);=20start=20=3D=20time.time()=0Dprint=20=
"running=20sys.modules=20loop"=0D=0Dfor=20m=20in=20sys.modules.values():=0D=
=20=20=20=20if=20hasattr(m,=20"__file__")=20and=20m.__file__:=0D=20=20=20=
=20=20=20=20=20m.__file__=20=3D=20os.path.abspath(m.__file__)=0Ddel=20m=0D=
=0D#=20This=20ensures=20that=20the=20initial=20path=20provided=20by=20=
the=20interpreter=20contains=0D#=20only=20absolute=20pathnames,=20even=20=
if=20we're=20running=20from=20the=20build=20directory.=0Dprint=20=
"elapsed=20time=20is:=20%.2f=20seconds"%(time.time()-start,=20);=20start=20=
=3D=20time.time()=0Dprint=20"starting=20absolute=20path=20routine"=0D=0D=
L=20=3D=20[]=0D_dirs_in_sys_path=20=3D=20{}=0Dfor=20dir=20in=20sys.path:=0D=
=20=20=20=20print=20"elapsed=20time=20is:=20%.2f=20=
seconds"%(time.time()-start,=20);=20start=20=3D=20time.time()=0D=20=20=20=
=20print=20"Inside=20absolute=20path=20loop,=20dir=20=3D=20%s"%dir=0D=0D=20=
=20=20=20#=20Filter=20out=20paths=20that=20don't=20exist,=20but=20leave=20=
in=20the=20empty=20string=0D=20=20=20=20#=20since=20it's=20a=20special=20=
case.=20We=20also=20need=20to=20special-case=20the=20Mac,=0D=20=20=20=20=
#=20as=20file=20names=20are=20allowed=20on=20sys.path=20there.=0D=20=20=20=
=20if=20sys.platform=20!=3D=20'mac':=0D=20=20=20=20=20=20=20=20if=20dir=20=
and=20not=20os.path.isdir(dir):=0D=20=20=20=20=20=20=20=20=20=20=20=20=
continue=0D=20=20=20=20else:=0D=20=20=20=20=20=20=20=20if=20dir=20and=20=
not=20os.path.exists(dir):=0D=20=20=20=20=20=20=20=20=20=20=20=20=
continue=0D=20=20=20=20dir,=20dircase=20=3D=20makepath(dir)=0D=20=20=20=20=
if=20not=20_dirs_in_sys_path.has_key(dircase):=0D=20=20=20=20=20=20=20=20=
L.append(dir)=0D=20=20=20=20=20=20=20=20_dirs_in_sys_path[dircase]=20=3D=20=
1=0Dsys.path[:]=20=3D=20L=0Ddel=20dir,=20L=0D=0Dprint=20"elapsed=20time=20=
is:=20%.2f=20seconds"%(time.time()-start,=20);=20start=20=3D=20=
time.time()=0Dprint=20'running=20"=20append=20./build...'=0D=0D=0D#=20=
Append=20./build/lib.<platform>=20in=20case=20we're=20running=20in=20the=20=
build=20dir=0D#=20(especially=20for=20Guido=20:-)=0Dif=20(os.name=20=3D=3D=
=20"posix"=20and=20sys.path=20and=0D=20=20=20=20=
os.path.basename(sys.path[-1])=20=3D=3D=20"Modules"):=0D=20=20=20=20from=20=
distutils.util=20import=20get_platform=0D=20=20=20=20s=20=3D=20=
"build/lib.%s-%.3s"=20%=20(get_platform(),=20sys.version)=0D=20=20=20=20=
s=20=3D=20os.path.join(os.path.dirname(sys.path[-1]),=20s)=0D=20=20=20=20=
sys.path.append(s)=0D=20=20=20=20del=20get_platform,=20s=0D=0Ddef=20=
_init_pathinfo():=0D=20=20=20=20global=20_dirs_in_sys_path=0D=20=20=20=20=
_dirs_in_sys_path=20=3D=20d=20=3D=20{}=0D=20=20=20=20for=20dir=20in=20=
sys.path:=0D=20=20=20=20=20=20=20=20if=20dir=20and=20not=20=
os.path.isdir(dir):=0D=20=20=20=20=20=20=20=20=20=20=20=20continue=0D=20=20=
=20=20=20=20=20=20dir,=20dircase=20=3D=20makepath(dir)=0D=20=20=20=20=20=20=
=20=20d[dircase]=20=3D=201=0D=0Ddef=20addsitedir(sitedir):=0D=20=20=20=20=
global=20_dirs_in_sys_path=0D=20=20=20=20if=20_dirs_in_sys_path=20is=20=
None:=0D=20=20=20=20=20=20=20=20_init_pathinfo()=0D=20=20=20=20=20=20=20=20=
reset=20=3D=201=0D=20=20=20=20else:=0D=20=20=20=20=20=20=20=20reset=20=3D=20=
0=0D=20=20=20=20sitedir,=20sitedircase=20=3D=20makepath(sitedir)=0D=20=20=
=20=20if=20not=20_dirs_in_sys_path.has_key(sitedircase):=0D=20=20=20=20=20=
=20=20=20sys.path.append(sitedir)=20=20=20=20=20=20=20=20#=20Add=20path=20=
component=0D=20=20=20=20try:=0D=20=20=20=20=20=20=20=20names=20=3D=20=
os.listdir(sitedir)=0D=20=20=20=20except=20os.error:=0D=20=20=20=20=20=20=
=20=20return=0D=20=20=20=20names.sort()=0D=20=20=20=20for=20name=20in=20=
names:=0D=20=20=20=20=20=20=20=20if=20name[-4:]=20=3D=3D=20os.extsep=20+=20=
"pth":=0D=20=20=20=20=20=20=20=20=20=20=20=20addpackage(sitedir,=20name)=0D=
=20=20=20=20if=20reset:=0D=20=20=20=20=20=20=20=20_dirs_in_sys_path=20=3D=20=
None=0D=0Ddef=20addpackage(sitedir,=20name):=0D=20=20=20=20global=20=
_dirs_in_sys_path=0D=20=20=20=20if=20_dirs_in_sys_path=20is=20None:=0D=20=
=20=20=20=20=20=20=20_init_pathinfo()=0D=20=20=20=20=20=20=20=20reset=20=
=3D=201=0D=20=20=20=20else:=0D=20=20=20=20=20=20=20=20reset=20=3D=200=0D=20=
=20=20=20fullname=20=3D=20os.path.join(sitedir,=20name)=0D=20=20=20=20=
try:=0D=20=20=20=20=20=20=20=20f=20=3D=20open(fullname)=0D=20=20=20=20=
except=20IOError:=0D=20=20=20=20=20=20=20=20return=0D=20=20=20=20while=20=
1:=0D=20=20=20=20=20=20=20=20dir=20=3D=20f.readline()=0D=20=20=20=20=20=20=
=20=20if=20not=20dir:=0D=20=20=20=20=20=20=20=20=20=20=20=20break=0D=20=20=
=20=20=20=20=20=20if=20dir[0]=20=3D=3D=20'#':=0D=20=20=20=20=20=20=20=20=20=
=20=20=20continue=0D=20=20=20=20=20=20=20=20if=20=
dir.startswith("import"):=0D=20=20=20=20=20=20=20=20=20=20=20=20exec=20=
dir=0D=20=20=20=20=20=20=20=20=20=20=20=20continue=0D=20=20=20=20=20=20=20=
=20if=20dir[-1]=20=3D=3D=20'\n':=0D=20=20=20=20=20=20=20=20=20=20=20=20=
dir=20=3D=20dir[:-1]=0D=20=20=20=20=20=20=20=20dir,=20dircase=20=3D=20=
makepath(sitedir,=20dir)=0D=20=20=20=20=20=20=20=20if=20not=20=
_dirs_in_sys_path.has_key(dircase)=20and=20os.path.exists(dir):=0D=20=20=20=
=20=20=20=20=20=20=20=20=20sys.path.append(dir)=0D=20=20=20=20=20=20=20=20=
=20=20=20=20_dirs_in_sys_path[dircase]=20=3D=201=0D=20=20=20=20if=20=
reset:=0D=20=20=20=20=20=20=20=20_dirs_in_sys_path=20=3D=20None=0D=0D=
print=20"elapsed=20time=20is:=20%.2f=20seconds"%(time.time()-start,=20);=20=
start=20=3D=20time.time()=0Dprint=20"running=20prefixes..."=0D=0D=
prefixes=20=3D=20[sys.prefix]=0Dif=20sys.exec_prefix=20!=3D=20=
sys.prefix:=0D=20=20=20=20prefixes.append(sys.exec_prefix)=0Dfor=20=
prefix=20in=20prefixes:=0D=20=20=20=20if=20prefix:=0D=20=20=20=20=20=20=20=
=20if=20os.sep=20=3D=3D=20'/':=0D=20=20=20=20=20=20=20=20=20=20=20=20=
sitedirs=20=3D=20[os.path.join(prefix,=0D=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20"lib",=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20"python"=20+=20=
sys.version[:3],=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
"site-packages"),=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20os.path.join(prefix,=20"lib",=20"site-python")]=0D=20=20=
=20=20=20=20=20=20else:=0D=20=20=20=20=20=20=20=20=20=20=20=20sitedirs=20=
=3D=20[prefix,=20os.path.join(prefix,=20"lib",=20"site-packages")]=0D=20=20=
=20=20=20=20=20=20for=20sitedir=20in=20sitedirs:=0D=20=20=20=20=20=20=20=20=
=20=20=20=20if=20os.path.isdir(sitedir):=0D=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20addsitedir(sitedir)=0D=0D_dirs_in_sys_path=20=3D=20=
None=0D=0Dprint=20"elapsed=20time=20is:=20%.2f=20=
seconds"%(time.time()-start,=20);=20start=20=3D=20time.time()=0Dprint=20=
"defining=20quit=20and=20exit"=0D=0D#=20Define=20new=20built-ins=20=
'quit'=20and=20'exit'.=0D#=20These=20are=20simply=20strings=20that=20=
display=20a=20hint=20on=20how=20to=20exit.=0Dif=20os.sep=20=3D=3D=20':':=0D=
=20=20=20=20exit=20=3D=20'Use=20Cmd-Q=20to=20quit.'=0Delif=20os.sep=20=3D=3D=
=20'\\':=0D=20=20=20=20exit=20=3D=20'Use=20Ctrl-Z=20plus=20Return=20to=20=
exit.'=0Delse:=0D=20=20=20=20exit=20=3D=20'Use=20Ctrl-D=20(i.e.=20EOF)=20=
to=20exit.'=0Dimport=20__builtin__=0D__builtin__.quit=20=3D=20=
__builtin__.exit=20=3D=20exit=0Ddel=20exit=0D=0D#=20interactive=20prompt=20=
objects=20for=20printing=20the=20license=20text,=20a=20list=20of=0D#=20=
contributors=20and=20the=20copyright=20notice.=0Dclass=20_Printer:=0D=20=20=
=20=20MAXLINES=20=3D=2023=0D=0D=20=20=20=20def=20__init__(self,=20name,=20=
data,=20files=3D(),=20dirs=3D()):=0D=20=20=20=20=20=20=20=20self.__name=20=
=3D=20name=0D=20=20=20=20=20=20=20=20self.__data=20=3D=20data=0D=20=20=20=
=20=20=20=20=20self.__files=20=3D=20files=0D=20=20=20=20=20=20=20=20=
self.__dirs=20=3D=20dirs=0D=20=20=20=20=20=20=20=20self.__lines=20=3D=20=
None=0D=0D=20=20=20=20def=20__setup(self):=0D=20=20=20=20=20=20=20=20if=20=
self.__lines:=0D=20=20=20=20=20=20=20=20=20=20=20=20return=0D=20=20=20=20=
=20=20=20=20data=20=3D=20None=0D=20=20=20=20=20=20=20=20for=20dir=20in=20=
self.__dirs:=0D=20=20=20=20=20=20=20=20=20=20=20=20for=20file=20in=20=
self.__files:=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20file=20=3D=
=20os.path.join(dir,=20file)=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20try:=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
fp=20=3D=20open(file)=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20data=20=3D=20fp.read()=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20fp.close()=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20break=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20except=20IOError:=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20pass=0D=20=20=20=20=20=20=20=20=20=20=20=20if=20data:=0D=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20break=0D=20=20=20=20=20=20=20=20=
if=20not=20data:=0D=20=20=20=20=20=20=20=20=20=20=20=20data=20=3D=20=
self.__data=0D=20=20=20=20=20=20=20=20self.__lines=20=3D=20=
data.split('\n')=0D=20=20=20=20=20=20=20=20self.__linecnt=20=3D=20=
len(self.__lines)=0D=0D=20=20=20=20def=20__repr__(self):=0D=20=20=20=20=20=
=20=20=20self.__setup()=0D=20=20=20=20=20=20=20=20if=20len(self.__lines)=20=
<=3D=20self.MAXLINES:=0D=20=20=20=20=20=20=20=20=20=20=20=20return=20=
"\n".join(self.__lines)=0D=20=20=20=20=20=20=20=20else:=0D=20=20=20=20=20=
=20=20=20=20=20=20=20return=20"Type=20%s()=20to=20see=20the=20full=20%s=20=
text"=20%=20((self.__name,)*2)=0D=0D=20=20=20=20def=20__call__(self):=0D=20=
=20=20=20=20=20=20=20self.__setup()=0D=20=20=20=20=20=20=20=20prompt=20=3D=
=20'Hit=20Return=20for=20more,=20or=20q=20(and=20Return)=20to=20quit:=20=
'=0D=20=20=20=20=20=20=20=20lineno=20=3D=200=0D=20=20=20=20=20=20=20=20=
while=201:=0D=20=20=20=20=20=20=20=20=20=20=20=20try:=0D=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20for=20i=20in=20range(lineno,=20lineno=20+=20=
self.MAXLINES):=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20print=20self.__lines[i]=0D=20=20=20=20=20=20=20=20=20=20=20=20except=20=
IndexError:=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20break=0D=20=
=20=20=20=20=20=20=20=20=20=20=20else:=0D=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20lineno=20+=3D=20self.MAXLINES=0D=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20key=20=3D=20None=0D=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20while=20key=20is=20None:=0D=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20key=20=3D=20raw_input(prompt)=0D=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20if=20key=20not=20in=20('',=20=
'q'):=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20key=20=3D=20None=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
if=20key=20=3D=3D=20'q':=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20break=0Dprint=20"elapsed=20time=20is:=20%.2f=20=
seconds"%(time.time()-start,=20);=20start=20=3D=20time.time()=0Dprint=20=
"printing=20credits"=0D=0D__builtin__.copyright=20=3D=20=
_Printer("copyright",=20sys.copyright)=0Dif=20sys.platform[:4]=20=3D=3D=20=
'java':=0D=20=20=20=20__builtin__.credits=20=3D=20_Printer(=0D=20=20=20=20=
=20=20=20=20"credits",=0D=20=20=20=20=20=20=20=20"Jython=20is=20=
maintained=20by=20the=20Jython=20developers=20(www.jython.org).")=0D=
else:=0D=20=20=20=20__builtin__.credits=20=3D=20_Printer("credits",=20=
"""\=0DThanks=20to=20CWI,=20CNRI,=20BeOpen.com,=20Digital=20Creations=20=
and=20a=20cast=20of=20thousands=0Dfor=20supporting=20Python=20=
development.=20=20See=20www.python.org=20for=20more=20information.""")=0D=
here=20=3D=20os.path.dirname(os.__file__)=0D__builtin__.license=20=3D=20=
_Printer(=0D=20=20=20=20"license",=20"See=20=
http://www.python.org/%.3s/license.html"=20%=20sys.version,=0D=20=20=20=20=
["LICENSE.txt",=20"LICENSE"],=0D=20=20=20=20[os.path.join(here,=20=
os.pardir),=20here,=20os.curdir])=0D=0D=0D#=20Define=20new=20built-in=20=
'help'.=0D#=20This=20is=20a=20wrapper=20around=20pydoc.help=20(with=20a=20=
twist).=0Dclass=20_Helper:=0D=20=20=20=20def=20__repr__(self):=0D=20=20=20=
=20=20=20=20=20return=20"Type=20help()=20for=20interactive=20help,=20"=20=
\=0D=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20"or=20help(object)=20=
for=20help=20about=20object."=0D=20=20=20=20def=20__call__(self,=20=
*args,=20**kwds):=0D=20=20=20=20=20=20=20=20import=20pydoc=0D=20=20=20=20=
=20=20=20=20return=20pydoc.help(*args,=20**kwds)=0Dprint=20"elapsed=20=
time=20is:=20%.2f=20seconds"%(time.time()-start,=20);=20start=20=3D=20=
time.time()=0Dprint=20"defining=20new=20help"=0D=0D__builtin__.help=20=3D=20=
_Helper()=0D=0D=0D#=20Set=20the=20string=20encoding=20used=20by=20the=20=
Unicode=20implementation.=20=20The=0D#=20default=20is=20'ascii',=20but=20=
if=20you're=20willing=20to=20experiment,=20you=20can=0D#=20change=20=
this.=0D=0Dprint=20"elapsed=20time=20is:=20%.2f=20=
seconds"%(time.time()-start,=20);=20start=20=3D=20time.time()=0Dprint=20=
"setting=20string=20encoding"=0D=0Dencoding=20=3D=20"ascii"=20#=20=
Default=20value=20set=20by=20_PyUnicode_Init()=0D=0Dif=200:=0D=20=20=20=20=
#=20Enable=20to=20support=20locale=20aware=20default=20string=20=
encodings.=0D=20=20=20=20import=20locale=0D=20=20=20=20loc=20=3D=20=
locale.getdefaultlocale()=0D=20=20=20=20if=20loc[1]:=0D=20=20=20=20=20=20=
=20=20encoding=20=3D=20loc[1]=0D=0Dif=200:=0D=20=20=20=20#=20Enable=20to=20=
switch=20off=20string=20to=20Unicode=20coercion=20and=20implicit=0D=20=20=
=20=20#=20Unicode=20to=20string=20conversion.=0D=20=20=20=20encoding=20=3D=
=20"undefined"=0D=0Dif=20encoding=20!=3D=20"ascii":=0D=20=20=20=20#=20On=20=
Non-Unicode=20builds=20this=20will=20raise=20an=20AttributeError...=0D=20=
=20=20=20sys.setdefaultencoding(encoding)=20#=20Needs=20Python=20Unicode=20=
build=20!=0D=0D#=0D#=20Run=20custom=20site=20specific=20code,=20if=20=
available.=0D#=0Dprint=20"elapsed=20time=20is:=20%.2f=20=
seconds"%(time.time()-start,=20);=20start=20=3D=20time.time()=0Dprint=20=
"trying=20to=20import=20sitecustomize"=0D=0Dtry:=0D=20=20=20=20import=20=
sitecustomize=0Dexcept=20ImportError:=0D=20=20=20=20pass=0D=0D#=0D#=20=
Remove=20sys.setdefaultencoding()=20so=20that=20users=20cannot=20change=20=
the=0D#=20encoding=20after=20initialization.=20=20The=20test=20for=20=
presence=20is=20needed=20when=0D#=20this=20module=20is=20run=20as=20a=20=
script,=20because=20this=20code=20is=20executed=20twice.=0D#=0Dprint=20=
"elapsed=20time=20is:=20%.2f=20seconds"%(time.time()-start,=20);=20start=20=
=3D=20time.time()=0Dprint=20"removing=20sys.setdefaultencoding()"=0Dif=20=
hasattr(sys,=20"setdefaultencoding"):=0D=20=20=20=20del=20=
sys.setdefaultencoding=0D=0Ddef=20_test():=0D=20=20=20=20print=20=
"sys.path=20=3D=20["=0D=20=20=20=20for=20dir=20in=20sys.path:=0D=20=20=20=
=20=20=20=20=20print=20"=20=20=20=20%s,"=20%=20`dir`=0D=20=20=20=20print=20=
"]"=0Dprint=20"elapsed=20time=20is:=20%.2f=20=
seconds"%(time.time()-start,=20)=0D=0Dif=20__name__=20=3D=3D=20=
'__main__':=0D=20=20=20=20_test()=0D=

--Apple-Mail-2--91202036
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed





Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov


--Apple-Mail-2--91202036--