Nick Coghlan <ncogh...@gmail.com> added the comment:

Attached patch is a very rough first cut at this. I've gone with the basic 
approach of simply assigning the literals to local variables in each function 
that uses them. My rationale for that is:
1. Every function has to have some kind of boilerplate to switch based on the 
type of the argument
2. Some functions need to switch other values (such as the list of scheme_chars 
or the unparse function), so a separate object with literal attributes won't be 
enough
3. Given 1 and 2, the overhead of a separate namespace for the literal 
references isn't justified

I've also gone with a philosophy that only str objects are treated as strings 
and everything else is implicitly assumed to be bytes. This is in keeping with 
the general interpreter behaviour where we *really* don't support duck-typing 
when it comes to strings.

The test updates aren't comprehensive yet, but they were enough to uncover 
quite a few things I had missed.

quoting is still a bit ugly, so I may still add a byte->bytes/str->str variant 
of those APIs.

----------
keywords: +patch
Added file: http://bugs.python.org/file19043/issue9873_initial_attempt.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9873>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to