Optimizing Inner Loop Copy

2006-08-17 Thread Mark E. Fenner
Hello all, I have a code where my inner loop looks like: allNew = [] for params in cases: newObj = copy(initialObject) newObj.modify(params) allNew.append(newObj) return allNew and the copy is taking the majority (42%) of my execution time. So, I'd like to speed up my copy. I had an

Re: Optimizing Inner Loop Copy

2006-08-17 Thread Michael Spencer
Mark E. Fenner wrote: > > and the copy is taking the majority (42%) of my execution time. > So, I'd like to speed up my copy. I had an explicit copy method that did > what was needed and returned a new object, but this was quite a bit slower > than using the standard lib copy.copy(). > How are

Re: Optimizing Inner Loop Copy

2006-08-17 Thread Mark E. Fenner
Michael Spencer wrote: > Mark E. Fenner wrote: > >> >> and the copy is taking the majority (42%) of my execution time. >> So, I'd like to speed up my copy. I had an explicit copy method that did >> what was needed and returned a new object, but this was quite a bit >> slower than using the stan

Re: Optimizing Inner Loop Copy

2006-08-17 Thread John Machin
Mark E. Fenner wrote: > Here's my class of the objects being copied: Here's a couple of things that might help speed up your __init__ method, and hence your copy method: > > class Rule(list): > def __init__(self, lhs=None, rhs=None, nClasses=0, nCases=0): def __init__(self, lhs=None, r

Re: Optimizing Inner Loop Copy

2006-08-17 Thread Mark E. Fenner
John Machin wrote: > > Mark E. Fenner wrote: > >> Here's my class of the objects being copied: > > Here's a couple of things that might help speed up your __init__ > method, and hence your copy method: > >> >> class Rule(list): >> def __init__(self, lhs=None, rhs=None, nClasses=0, nCases=0

Re: Optimizing Inner Loop Copy

2006-08-17 Thread Mark E. Fenner
Mark E. Fenner wrote: > John Machin wrote: > >> >> Mark E. Fenner wrote: >> >>> Here's my class of the objects being copied: >> >> Here's a couple of things that might help speed up your __init__ >> method, and hence your copy method: >> >>> >>> class Rule(list): >>> def __init__(self, lh

Re: Optimizing Inner Loop Copy

2006-08-17 Thread Michael Spencer
Mark E. Fenner wrote: > Michael Spencer wrote: > >> Mark E. Fenner wrote: >> >>> and the copy is taking the majority (42%) of my execution time. >>> So, I'd like to speed up my copy. I had an explicit copy method that did >>> what was needed and returned a new object, but this was quite a bit >>>

Re: Optimizing Inner Loop Copy

2006-08-17 Thread danielx
Mark E. Fenner wrote: > Mark E. Fenner wrote: > > > John Machin wrote: > > > >> > >> Mark E. Fenner wrote: > >> > >>> Here's my class of the objects being copied: > >> > >> Here's a couple of things that might help speed up your __init__ > >> method, and hence your copy method: > >> > >>> > >>> cl

Re: Optimizing Inner Loop Copy

2006-08-17 Thread Mark E. Fenner
danielx wrote: > > Mark E. Fenner wrote: >> Mark E. Fenner wrote: >> >> > John Machin wrote: >> > >> >> >> >> Mark E. Fenner wrote: >> >> >> >>> Here's my class of the objects being copied: >> >> >> >> Here's a couple of things that might help speed up your __init__ >> >> method, and hence your c

Re: Optimizing Inner Loop Copy

2006-08-18 Thread Paul McGuire
"Mark E. Fenner" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello all, > > > Here's my class of the objects being copied: > > class Rule(list): > def __init__(self, lhs=None, rhs=None, nClasses=0, nCases=0): > self.nClasses = nClasses > self.nCases = nCases >

Re: Optimizing Inner Loop Copy

2006-08-18 Thread Mark E. Fenner
Paul McGuire wrote: > "Mark E. Fenner" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Hello all, >> > >> >> Here's my class of the objects being copied: >> >> class Rule(list): >> def __init__(self, lhs=None, rhs=None, nClasses=0, nCases=0): >> self.nClasses = nClass

Re: Optimizing Inner Loop Copy

2006-08-18 Thread Paul McGuire
"Mark E. Fenner" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Save inheritance for the true "is-a" relationships among your problem > > domain > > classes. For instance, define a base Rule class, and then you can extend > > it with things like DeterministicRule, ProbabilisticRul

Re: Optimizing Inner Loop Copy

2006-08-19 Thread danielx
Mark E. Fenner wrote: > Paul McGuire wrote: > > > "Mark E. Fenner" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> Hello all, > >> > > > >> > >> Here's my class of the objects being copied: > >> > >> class Rule(list): > >> def __init__(self, lhs=None, rhs=None, nClasses=0,