[Python-checkins] peps: Address more comments
antoine.pitrou
python-checkins at python.org
Fri Sep 13 22:43:38 CEST 2013
http://hg.python.org/peps/rev/3663de7135a2
changeset: 5109:3663de7135a2
user: Antoine Pitrou <solipsis at pitrou.net>
date: Fri Sep 13 22:43:34 2013 +0200
summary:
Address more comments
files:
pep-0455.txt | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/pep-0455.txt b/pep-0455.txt
--- a/pep-0455.txt
+++ b/pep-0455.txt
@@ -28,7 +28,9 @@
which matches keys in a case-insensitive fashion but retains the original
casing. It is a very common need in network programming, as many
protocols feature some arrays of "key / value" properties in their
-messages, where the keys are textual strings whose casing isn't relevant.
+messages, where the keys are textual strings whose case is specified to
+be ignored on receipt but by either specification or custom is to be
+preserved or non-trivially canonicalized when retransmitted.
Another common request is an identity dict, where keys are matched
according to their respective id()s instead of normal matching.
@@ -144,6 +146,25 @@
is that it's nearly as cheap (code-wise and performance-wise) to provide
the generic construct, and it can fill more use cases.
+Other constructor patterns
+--------------------------
+
+Two other constructor patterns were proposed by Serhiy Storchaka:
+
+* A type factory scheme::
+
+ d = TransformDict(str.casefold)(Foo=1)
+
+* A subclassing scheme::
+
+ class CaseInsensitiveDict(TransformDict):
+ __transform__ = str.casefold
+
+ d = CaseInsensitiveDict(Foo=1)
+
+While both approaches can be defended, they don't follow established
+practices in the standard library, and therefore were rejected.
+
Implementation
==============
--
Repository URL: http://hg.python.org/peps
More information about the Python-checkins
mailing list