Schwartzian Transform (was Re: Sort)

Steven D. Majewski sdm7g at virginia.edu
Wed Dec 6 14:16:53 EST 2000


On Wed, 6 Dec 2000, Alex Martelli wrote:

> The technique is named after its inventor Randall
> Schwartz, who thought it up in the context of Perl
> (but it works even better in Python:-).  The key
> idea is that, in scripting languages such as Perl
> and Python, 'sort' slows down a lot if each of its
> O(N log N) comparison involves interpreting script
> code, rather than just the fast, built-in "lexical
> comparison" that the language provides.


This is however, a pretty ancient Python idiom, so I wonder
about attributing it to Randall's invention. 
( Unfortunately, it doesn't distill into an obvious regex 
  to grep thru the old mailings archives for a first use.) 

-- Steve Majewski <sdm7g at Virginia.EDU> 





More information about the Python-list mailing list