PEP263 (Specifying encoding) and bytecode strings

Bengt Richter bokr at oz.net
Tue May 6 15:41:19 EDT 2003


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

>> >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, but you are right
that the string _source_ literal would be compressible about 2:1,
and more if the binary is also compressible.

Regards,
Bengt Richter




More information about the Python-list mailing list