This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients gvanrossum, janssen, jimjjewett, loewis, mgiuca, orsenthil, pitrou, thomaspinckney3
Date 2008-08-13.16:02:05
SpamBayes Score 1.49565e-06
Marked as misclassified No
Message-id <>
In-reply-to <>
Selon Matt Giuca <>:
> > Now that you've spent so  much time with this patch, can't you think
> > of a faster way of doing this?
> Well firstly, you could replace Quoter (the class) with a "quoter"
> function, which is nested inside quote. Would calling a nested function
> be faster than a method call?

The obvious speedup is to remove the map() call and do the loop inside
Quoter.__call__ instead. That way you don't have any function or method call in
the critical path.

(also, defining a class with a single __call__ method is not a common Python
idiom; usually you'd just have a function returning another (nested) function)

As for the defaultdict, here is how it can look like (this is on 2.5):

...  def __missing__(self, key):
...   print "__missing__", key
...   value = "%%%02X" % key
...   self[key] = value
...   return value
>>> d = D()
>>> d[66] = 'B'
>>> d[66]
>>> d[67]
__missing__ 67
>>> d[67]
Date User Action Args
2008-08-13 16:02:07pitrousetrecipients: + pitrou, gvanrossum, loewis, jimjjewett, janssen, orsenthil, thomaspinckney3, mgiuca
2008-08-13 16:02:06pitroulinkissue3300 messages
2008-08-13 16:02:05pitroucreate