wheres pythonmonks wrote: > How do I build an "int1" type that has a default value of 1? > [Hopefully no speed penalty.] > I am thinking about applications with collections.defaultdict.
>>> from collections import defaultdict >>> d = defaultdict(1 .conjugate) >>> d["x"] += 2 >>> d["x"] 3 Isn't that beautiful? Almost like home;) It is also fast: $ python -m timeit -s"one = lambda: 1" "one()" 1000000 loops, best of 3: 0.213 usec per loop $ python -m timeit -s"one = 1 .conjugate" "one()" 10000000 loops, best of 3: 0.0972 usec per loop Micro-optimisation, the best excuse for ugly code... Peter -- http://mail.python.org/mailman/listinfo/python-list