Debug Build of Python

2007-02-21 Thread Mark E. Fenner
Hi all, Just curious how to get an all bells and whistles debug build of python. In the source for 2.4.3, I see the following debug related options: From README: (1) e.g. make OPT=-g will build a debugging version of Python on most platforms (2) Additional debugging code to help debug memory

From bags to default dicts

2006-09-12 Thread Mark E. Fenner
Hello all, I was curious if anyone has transitioned some code from using Raymond Hettinger's bag class: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/259174 to using 2.5's collections.defaultdict. Any pitfalls to watch out for? It seems we should be able to do slightly better than

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, snip 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

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

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 standard lib

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): def

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, lhs=None, rhs=None, nClasses

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 copy method: class Rule(list

Re: frozenset/subclassing/keyword args

2005-11-01 Thread Mark E. Fenner
Without researching it, I would guess that you have to override __new__ so as not to pass through the myName arg to the otherwise inherited and called-with-all-arguments __new__ of the base class. snip Regards, Bengt Richter Bengt, Thanks as always! Python's rabbit holes always go a

frozenset/subclassing/keyword args

2005-10-31 Thread Mark E. Fenner
Hello all, I was migrating some code from sets.ImmutableSet to frozenset and noticed the following: **code #!/usr/bin/env python from sets import ImmutableSet class MSet1(ImmutableSet): def __init__(self, iterArg, myName=foo): ImmutableSet.__init__(self, iterArg)

Memoization/Caching of Instance Methods

2005-03-24 Thread Mark E. Fenner
In the code below, the class DifferentCache utilizes three different memoization (caching) strategies. Neither the function Memoize1 or the class Memoize2 will be adequate for all three of these cases (I intend these to be used as, for example, getInstanceValueFunction =