You might want to switch back to list comprehensions.  Granted the code is uglier but there are two big reasons.

1) Speed. See http://www.daniweb.com/forums/thread32869.html for more info.
    You could wrap the inner loop inner workings in a function and still reap massive benefits
    by not having to call list.append() n^2 times.
2) It's recommended for building lists in Py3k.

The results of the above linked test are:

[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58]
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58]

Profile of evenList1(), check the time consumed by the many append() calls:
(ignore time consumed by the profiler itself)

         50005 function calls in 0.174 CPU seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    50000    0.066    0.000    0.066    0.000 :0(append)
        1    0.002    0.002    0.002    0.002 :0(range)
        1    0.005    0.005    0.005    0.005 :0(setprofile)
        1    0.001    0.001    0.168    0.168 <string>:1(<module>)
        1    0.100    0.100    0.168    0.168 Script1.py:5(evenList1)
        1    0.000    0.000    0.174    0.174 profile:0(evenList1())
        0    0.000             0.000          profile:0(profiler)


Profile of evenList2():
(ignore time consumed by the profiler itself)

         5 function calls in 0.018 CPU seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.002    0.002    0.002    0.002 :0(range)
        1    0.000    0.000    0.000    0.000 :0(setprofile)
        1    0.001    0.001    0.018    0.018 <string>:1(<module>)
        1    0.015    0.015    0.017    0.017 Script1.py:15(evenList2)
        1    0.000    0.000    0.018    0.018 profile:0(evenList2())
        0    0.000             0.000          profile:0(profiler)


mdipierro wrote:
OK. it is in trunk but slightly different. The representation is now
independent on the database backend.

Massimo

On Dec 29, 8:04 am, Timothy Farrell <tfarr...@swgen.com> wrote:
  
Massimo, would it help if I made a bzr branch?
Timothy Farrell wrote:I've been using this in my setup (my setup has a few customizations) since the thread linked below.  Just to say that it works!
-tim
vince wrote:http://groups.google.com/group/web2py/browse_thread/thread/8e3e33879974663f/64f76c562366aec4?lnk=gst&q=json#64f76c562366aec4will it be added or we'll have to wait? i think it's hard to avoid all dependency contrib / thirdparty package. as long as it's include i think that's fine. -vince-- Timothy Farrell<tfarr...@swgen.com>Computer Guy Statewide General Insurance Agency (www.swgen.com)-- Timothy Farrell<tfarr...@swgen.com>Computer Guy Statewide General Insurance Agency (www.swgen.com)
    

  

-- 
Timothy Farrell <tfarr...@swgen.com>
Computer Guy
Statewide General Insurance Agency (www.swgen.com)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to