PEP263 (Specifying encoding) and bytecode strings

Michael Hudson mwh at python.net
Wed May 7 06:52:43 EDT 2003


bokr at oz.net (Bengt Richter) writes:

> On Tue, 6 May 2003 17:56:07 GMT, Michael Hudson <mwh at python.net> wrote:
> 
> >bokr at oz.net (Bengt Richter) writes:
> >
> >> On Tue, 6 May 2003 16:45:44 GMT, Michael Hudson <mwh at python.net> wrote:
> >> 
> >> >I'm deeply unconvinced that inserting binary data into string literals
> >> >is a common enough need to add language support.  Disk space is cheap,
> >> "Build it and they will come" ;-) It's not a matter of whether it
> >> _is_ common enough, it's a matter of whether it would be.
> >
> >Eh?  OK, it's also lousy style.  It seems to me that the fact that
> >people are tempted to embed chunks of binary data into string literals
> >is evidence that distutils' and other bits of infrastructure's support
> >for application data files is lacking, and this is where any energy
> >should be concentrated to fix the problem.
> >
> Hm, what would you say to being able to type
> 
>     python bag_o_stuff.zip
> 
> and have it execute the first .py file in the zip file and have a
> convenient builtin for a file executed like that to open files
> in the directory tree of the zip file it was executed out of, e.g.,
> 
>     f = selfzipfile('/some_dir/some_file.ext','rb') # '/' root relative to zip file content

That would be cool, but it's more the domain of stuff like py2exe
isn't it?  I have to admit, I don't currently distribute any
significant Python apps, so I probably don't have the keenest
appreciation of the issues.

What I had in mind was distutils support for installing files in, say,
${prefix}/share/myApp on Unix, {,~}/Library/Application Support/myApp
on Mac OS X, etc, and then having an easy way to *find the damn files
again* (which is currently AIUI the hard bit).

> >> >people!  And these files should compress well, too.
> >> Which files should compress well? Some do, some don't, ISTM.
> >
> >Files that contain lots of \xAB escapes.
> >
> I don't think you'd see those in the .pyc file,

No.

> but you are right that the string _source_ literal would be
> compressible about 2:1, and more if the binary is also compressible.

Yeah, that's what I meant.

Cheers,
M.

-- 
  > With Python you can start a thread, but you can't stop it.  Sorry.
  > You'll have to wait until reaches the end of execution.
  So, just the same as c.l.py, then?
                       -- Cliff Wells & Steve Holden, comp.lang.python




More information about the Python-list mailing list