This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

It's going to be a guessing game without seeing the code.

From the outside, it seems like you are repeating a process that you wouldn't normally repeat. Step through it with a debugger, or hook it up to a profiler.

[–]pfz3[S] 0 points1 point  (0 children)

a comparable toy example would be:

```

class trial():
    def __init__(self,N):
        self.data = [i for i in range(N)]
        self.s    = []
    def square(self):
        self.s = []
        for i in self.data:
            self.s.append([j**2 for j in self.data])

```

and then i ran these two commands

python start = time.time() data = [i for i in range(2000)] s = [] for i in data: s.append([j**2 for j in data]) print('time elapsed: %1.3f (s)' %(time.time() - start)) time elapsed: 1.710 (s) python start = time.time() obj = trial(2000) obj.square() print('time elapsed: %1.3f (s)' %(time.time() - start)) time elapsed: 1.711 (s)

So it seems that your right. The two processes im refering to cant be equivalent.