From bca1d412042c0977200f6737b327509ad1a4ac15 Mon Sep 17 00:00:00 2001 From: James G Sack Date: Thu, 27 Mar 2008 03:11:48 +0000 Subject: [PATCH] Some cleanup prior to an upcoming change for bug #1680. Minor optimization in _init_map (replace loop w/ list-comprehension Remove unused variables VALUE_POS, STRING_POS, At call to self.set, remove unnecessary logic that duplicates else-clause within the set() function itself svn: r10404 --- src/gen/lib/grampstype.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/gen/lib/grampstype.py b/src/gen/lib/grampstype.py index 1ece5739f..c1824341c 100644 --- a/src/gen/lib/grampstype.py +++ b/src/gen/lib/grampstype.py @@ -35,9 +35,8 @@ def _init_map(data, key_col, data_col): """ Initialize the map, building a new map from the specified columns. """ - new_data = {} - for item in data: - new_data[item[key_col]] = item[data_col] + new_data = dict([ (item[key_col], item[data_col]) + for item in data ]) return new_data class GrampsTypeMeta(type): @@ -53,7 +52,6 @@ class GrampsTypeMeta(type): class GrampsType(object): """Base class for all Gramps object types.""" - (VALUE_POS, STRING_POS) = range(2) _CUSTOM = 0 _DEFAULT = 0 @@ -75,11 +73,7 @@ class GrampsType(object): Create a new type, initialize the value from one of several possible states. """ - if value is not None: - self.set(value) - else: - self.val = self._DEFAULT - self.string = u'' + self.set(value) def __set_tuple(self, value): v,s = self._DEFAULT,u''