From 943abbce79e558358d30a33f3b4bb9be07b8ca27 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 6 Dec 2008 23:47:21 +0000 Subject: [PATCH] - removed creepy exec call for now - removed unnecessary isinstance() from class_mapper() - removed unnecessary and py3k incompatible "dictionary sort" from association table delete --- lib/sqlalchemy/orm/dependency.py | 1 - lib/sqlalchemy/orm/util.py | 2 -- lib/sqlalchemy/sql/visitors.py | 14 +++++++------- test/profiling/zoomark_orm.py | 4 ++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 2d0b7f1c68..fb24f6a680 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -444,7 +444,6 @@ class ManyToManyDP(DependencyProcessor): secondary_update.append(associationrow) if secondary_delete: - secondary_delete.sort() # TODO: precompile the delete/insert queries? statement = self.secondary.delete(sql.and_(*[c == sql.bindparam(c.key, type_=c.type) for c in self.secondary.c if c.key in associationrow])) result = connection.execute(statement, secondary_delete) diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py index 0615f41361..541adf4e41 100644 --- a/lib/sqlalchemy/orm/util.py +++ b/lib/sqlalchemy/orm/util.py @@ -531,8 +531,6 @@ def class_mapper(class_, compile=True): Raises UnmappedClassError if no mapping is configured. """ - if not isinstance(class_, type): - class_ = type(class_) try: class_manager = attributes.manager_of_class(class_) mapper = class_manager.mapper diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py index e6edce5e82..5d1d53cf8e 100644 --- a/lib/sqlalchemy/sql/visitors.py +++ b/lib/sqlalchemy/sql/visitors.py @@ -20,6 +20,7 @@ http://techspot.zzzeek.org/?p=19 . from collections import deque import re from sqlalchemy import util +import operator __all__ = ['VisitableType', 'Visitable', 'ClauseVisitor', 'CloningVisitor', 'ReplacingCloningVisitor', 'iterate', @@ -43,15 +44,14 @@ class VisitableType(type): # for use by the compiler visit_name = cls.__dict__["__visit_name__"] if isinstance(visit_name, str): - func_text = "def _compiler_dispatch(self, visitor, **kw):\n"\ - " return visitor.visit_%s(self, **kw)" % visit_name + getter = operator.attrgetter("visit_%s" % visit_name) + def _compiler_dispatch(self, visitor, **kw): + return getter(visitor)(self, **kw) else: - func_text = "def _compiler_dispatch(self, visitor, **kw):\n"\ - " return getattr(visitor, 'visit_%s' % self.__visit_name__)(self, **kw)" + def _compiler_dispatch(self, visitor, **kw): + return getattr(visitor, 'visit_%s' % self.__visit_name__)(self, **kw) - env = locals().copy() - exec func_text in env - cls._compiler_dispatch = env['_compiler_dispatch'] + cls._compiler_dispatch = _compiler_dispatch super(VisitableType, cls).__init__(clsname, bases, dict) diff --git a/test/profiling/zoomark_orm.py b/test/profiling/zoomark_orm.py index 831f60c805..8d5c28c69e 100644 --- a/test/profiling/zoomark_orm.py +++ b/test/profiling/zoomark_orm.py @@ -298,11 +298,11 @@ class ZooMarkTest(TestBase): def test_profile_2_insert(self): self.test_baseline_2_insert() - @profiling.function_call_count(6385) + @profiling.function_call_count(6783) def test_profile_3_properties(self): self.test_baseline_3_properties() - @profiling.function_call_count(22508) + @profiling.function_call_count(23861) def test_profile_4_expressions(self): self.test_baseline_4_expressions() -- 2.47.3