Author Jonathan.Livni
Recipients Jonathan.Livni, georg.brandl, rhettinger
Date 2011-02-16.13:51:27
SpamBayes Score 2.59025e-07
Marked as misclassified No
Message-id <1297864288.16.0.400090948968.issue11221@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2011-02-16 13:51:28Jonathan.Livnisetrecipients: + Jonathan.Livni, georg.brandl, rhettinger
2011-02-16 13:51:28Jonathan.Livnisetmessageid: <1297864288.16.0.400090948968.issue11221@psf.upfronthosting.co.za>
2011-02-16 13:51:27Jonathan.Livnilinkissue11221 messages
2011-02-16 13:51:27Jonathan.Livnicreate