[Zope-dev] Re: Speed win in Python's urllib.quote

Tres Seaver tseaver at palladion.com
Tue Sep 13 06:03:29 EDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris Withers wrote:

> Tres Seaver wrote:
> 
>> On further consideration (and after some more profiling), I would
>> actually prefer inlining the speedup code directly into
>> OFS.Traversable.Traversable, to remove the extra function call as well
>> as to avoid the gnarliness of monkey-patching Python.  
> 
> Fair enough :-)
> 
>> An alternative
>> would be to call 'quote' only once (for the completed string), rather
>> than repeatedly (for each path element).
> 
> Wouldn't that then encode all the /'es?

No -- urllib.quote takes a 'safe' argument, which defaults to '/', as an
extension to the 'always_safe' set::

  $ python2.3
  Python 2.3.5 (#2, Aug 30 2005, 13:43:24)
  [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> from urllib import quote
  >>> quote('/abc/def/ghi')
  '/abc/def/ghi'


Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDJqPx+gerLs4ltQ4RAqI4AKDEP6eiq/IzrYISuYM1AbJYAWQvWwCfXCYE
7AXqhMubzcfedZwO0Gr77x8=
=o9gI
-----END PGP SIGNATURE-----


More information about the Zope-Dev mailing list