On Sunday, 16 August 2015 at 13:11:12 UTC, Yura wrote:


Python:

#!/usr/bin/python
import sys, string, os, glob, random
from math import *

a = 0

l = 1000

for i in range(l):
        for j in range(l):
                for m in range(l):
                        a = a +i*i*0.7+j*j*0.8+m*m*0.9

print a


While starting over with D might make a better framework for going forward, it might be less work than you think to speed-up your existing Python code base. Loops in Python are notoriously slow. The code you're using seems like a classic example of something that could be sped up. You could write the slow parts in C with Cython. Alternately, you could play with Numba's @jit.

Reply via email to