[Zope-CMF] Re: CVS: Products/CMFDefault/skins/zpt_content - content_status_history.pt:1.4 transition_form.pt:1.3

Tres Seaver tseaver at zope.com
Tue Aug 3 16:33:06 EDT 2004


Jean-Marc Orliaguet wrote:
> Tres Seaver wrote:
> 
>> Paul Winkler wrote:
>>
>>> On Tue, Aug 03, 2004 at 10:49:05AM -0400, Tres Seaver wrote:
>>>
>>>> Yvo Schubbe wrote:
>>>>
>>>>> Update of /cvs-repository/Products/CMFDefault/skins/zpt_content
>>>>> In directory 
>>>>> cvs.zope.org:/tmp/cvs-serv27889/CMFDefault/skins/zpt_content
>>>>>
>>>>> Modified Files:
>>>>>     content_status_history.pt transition_form.pt Log Message:
>>>>> - replaced reverseList by [::-1] and marked reverseList as deprecated
>>>>
>>>>
>>>>
>>>> Oooh!  That is a brilliant hack!  I love it.
>>>
>>>
>>>
>>>
>>> It's a neat trick, but OTOH, it's kinda obscure, at least to CMF 
>>> users who are less well versed in python.  It strikes me as a bit 
>>> (dare I say it) perlish.
>>
>>
>>
>> Given that it allows me to get the list reversed in an expression, 
>> without the need for a do-nothing-else PythonScript, I'd still call it 
>> a win.   Vive l'idiom!
>>
>> Tres.
> 
> 
> 
> how big is the list?
> list.reverse() is almost almost twice as fast as [::-1] and seems to be 
> better optimized in terms of RAM usage, but of course if there are only 
> 3 items in the list, you are right.
> 
> and [::-1] doesn't work with python2.1, but that's OK I suppose?

The downside of 'reverse' is that it, like 'sort', is destructive, and 
(therefore) doesn't return the morphed thing.  'itertools.reverse' (only 
in 2.4) will be the Right Thing (TM) someday.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com



More information about the Zope-CMF mailing list