Jonathan Livni <jonathan.li...@gmail.com> added the comment:

The script I used is a single file single threaded code - but - It uses 
django's ORM to get the data from a MySQL database.

I've reduced the code path to this:

import sys,os
sys.path.append(os.path.dirname(os.getcwdu()))
os.environ['DJANGO_SETTINGS_MODULE']='my_app.settings'
from django.core.management import setup_environ
from my_app import settings
setup_environ(settings)

from my_app.convert.models import SomeModel
from operator import itemgetter
from decimal import Decimal

def non_decreasing(L):
    return all(x<=y for x, y in zip(L, L[1:]))    

raw_data =  
SomeModel.objects.filter(the_date=the_date,col1__gt=Decimal('0.2'),col2__gt=Decimal('0.2'),col3__gt=0,col4__gt=0,col5__gte=2).order_by('col6','col7','col8').values_list('col6','col7','col8','col1','col3','col2','col4')
data=defaultdict(list)

for d in raw_data:
        data[d[0],d[1]].append(d[2:])

for (exp,t),d in data.iteritems():
        col8s = map(itemgetter(0),d)
        mids = [(x[3]+x[4])/Decimal('2.0') for x in d]
        if not non_decreasing(mids):
                raise Exception

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11221>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to