From 8fd5f6369b9d4d3ccfa5fce7c0c605d6bb5b00e7 Mon Sep 17 00:00:00 2001 From: Robert Leftwich Date: Tue, 10 Jan 2006 23:15:54 +0000 Subject: [PATCH] r815@lightspeed: robert | 2006-01-11 10:15:14 +1100 Replaced use of repr() with custom identifiers in identity related areas to improve performance --- lib/sqlalchemy/mapping/objectstore.py | 5 +++-- lib/sqlalchemy/schema.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sqlalchemy/mapping/objectstore.py b/lib/sqlalchemy/mapping/objectstore.py index 5ca78b6f4b..5581d60ca5 100644 --- a/lib/sqlalchemy/mapping/objectstore.py +++ b/lib/sqlalchemy/mapping/objectstore.py @@ -34,7 +34,8 @@ def get_id_key(ident, class_, table): selectable - a Selectable object which represents all the object's column-based fields. this Selectable may be synonymous with the table argument or can be a larger construct containing that table. return value: a tuple object which is used as an identity key. """ - return (class_, repr(table), tuple(ident)) + return (class_, "Table(%d)" % id(table), tuple(ident)) + def get_row_key(row, class_, table, primary_key): """returns an identity-map key for use in storing/retrieving an item from the identity map, given a result set row. @@ -50,7 +51,7 @@ def get_row_key(row, class_, table, primary_key): this Selectable may be synonymous with the table argument or can be a larger construct containing that table. return value: a tuple object which is used as an identity key. """ - return (class_, repr(table), tuple([row[column] for column in primary_key])) + return (class_, "Table(%d)" % id(table), tuple([row[column] for column in primary_key])) def begin(): """begins a new UnitOfWork transaction. the next commit will affect only diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index b0cf931d88..511592e09a 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -40,7 +40,7 @@ class SchemaItem(object): def hash_key(self): """returns a string that identifies this SchemaItem uniquely""" - return repr(self) + return "%s(%d)" % (self.__class__.__name__, id(self)) def __repr__(self): return "%s()" % self.__class__.__name__ -- 2.47.2