[Chicago] Can you write Perl in Python?

Ian Bicking ianb at colorstudy.com
Wed Dec 28 19:54:24 CET 2005

Robert Kapteyn wrote:
> At first I was repulsed by this geekish waste of time . . .
> But I do have an idea . . .
> The since the contest is judged based on a character count and not a  
> byte count,
> I would suggest that you could greatly increase your compression  
> efficiency if the
> output was encoded in 16-bit unicode characters ;-)

Intriguing... but does Python accept source encoding that isn't 
ASCII-equivalent?  I didn't think it would.  But maybe UTF-32...

However, it would be neat if you could do:

# -*- coding: UTF-32 -*-
exec u'...utf-32 string...'.encode('unicode_internal').decode('zlib')

But can you actually get the internal format to match your expectations? 
  Well, probably...

And while they *say* they count characters, not bytes, are they telling 
the truth?  If they were counting characters, they'd have to follow PEP 
263, instead of just loading the file and counting bytes (which seems a 
more likely implementation).

And are they using a UCS-32 build of Python, or UCS-16?  At least I 
think those are the terms, and the 16-bit version is the default build 
(and default on most distros), and I think 32 bit Unicode is simply 
unrepresentable without it...?  Also, UTF-32 isn't a built-in encoding 
(or maybe it's just because of the Python build I'm using).  Of course 
UTF-16 would probably help too.

Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org

More information about the Chicago mailing list