]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Remove unnecessary tuple; prepare for "iterator" verbiage
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 20 Feb 2020 14:01:36 +0000 (09:01 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 20 Feb 2020 17:58:09 +0000 (12:58 -0500)
Remove a tuple surrounding a generator expression that
is immediately iterated in any case.   Additionally
note that the bulk methods can likely accept non-list
objects such as arbitrary iterables, however without test
coverage this is not yet guaranteed; use the term "sequence"
for now.

Also added a warmup to a cache key profiling test to get
consistent results.

Fixes: #5163
Change-Id: If838fe214da574763115855c1a65171533c96e64

lib/sqlalchemy/orm/session.py
test/aaa_profiling/test_misc.py
test/profiles.txt

index 9342c3145d78ec9e292c42cd88084ace14a46072..0950339516cf64d77d3c37234ae86e7d2acccbfe 100644 (file)
@@ -1190,7 +1190,7 @@ class Session(_SessionClassMethods):
         The second positional argument to :meth:`.Session.execute` is an
         optional parameter set.  Similar to that of
         :meth:`.Connection.execute`, whether this is passed as a single
-        dictionary, or a list of dictionaries, determines whether the DBAPI
+        dictionary, or a sequence of dictionaries, determines whether the DBAPI
         cursor's ``execute()`` or ``executemany()`` is used to execute the
         statement.   An INSERT construct may be invoked for a single row::
 
@@ -2716,7 +2716,7 @@ class Session(_SessionClassMethods):
             **before using this method, and fully test and confirm the
             functionality of all code developed using these systems.**
 
-        :param objects: a list of mapped object instances.  The mapped
+        :param objects: a sequence of mapped object instances.  The mapped
          objects are persisted as is, and are **not** associated with the
          :class:`.Session` afterwards.
 
@@ -2769,7 +2769,7 @@ class Session(_SessionClassMethods):
         def key(state):
             return (state.mapper, state.key is not None)
 
-        obj_states = tuple(attributes.instance_state(obj) for obj in objects)
+        obj_states = (attributes.instance_state(obj) for obj in objects)
         if not preserve_order:
             obj_states = sorted(obj_states, key=key)
 
@@ -2819,11 +2819,11 @@ class Session(_SessionClassMethods):
          representing the single kind of object represented within the mapping
          list.
 
-        :param mappings: a list of dictionaries, each one containing the state
-         of the mapped row to be inserted, in terms of the attribute names
-         on the mapped class.   If the mapping refers to multiple tables,
-         such as a joined-inheritance mapping, each dictionary must contain
-         all keys to be populated into all tables.
+        :param mappings: a sequence of dictionaries, each one containing the
+         state of the mapped row to be inserted, in terms of the attribute
+         names on the mapped class.   If the mapping refers to multiple tables,
+         such as a joined-inheritance mapping, each dictionary must contain all
+         keys to be populated into all tables.
 
         :param return_defaults: when True, rows that are missing values which
          generate defaults, namely integer primary key defaults and sequences,
@@ -2910,14 +2910,14 @@ class Session(_SessionClassMethods):
          representing the single kind of object represented within the mapping
          list.
 
-        :param mappings: a list of dictionaries, each one containing the state
-         of the mapped row to be updated, in terms of the attribute names
-         on the mapped class.   If the mapping refers to multiple tables,
-         such as a joined-inheritance mapping, each dictionary may contain
-         keys corresponding to all tables.   All those keys which are present
-         and are not part of the primary key are applied to the SET clause
-         of the UPDATE statement; the primary key values, which are required,
-         are applied to the WHERE clause.
+        :param mappings: a sequence of dictionaries, each one containing the
+         state of the mapped row to be updated, in terms of the attribute names
+         on the mapped class.   If the mapping refers to multiple tables, such
+         as a joined-inheritance mapping, each dictionary may contain keys
+         corresponding to all tables.   All those keys which are present and
+         are not part of the primary key are applied to the SET clause of the
+         UPDATE statement; the primary key values, which are required, are
+         applied to the WHERE clause.
 
 
         .. seealso::
index 8326a319045258871240cea5e9955726c9a1c528..f238fe8a721976363a12ff723a21125d4943b3a4 100644 (file)
@@ -105,7 +105,7 @@ class CacheKeyTest(fixtures.TestBase):
             for i in range(100)
         ]
 
-    @profiling.function_call_count()
+    @profiling.function_call_count(variance=0.15, warmup=1)
     def test_statement_one(self, stmt_fixture_one):
         current_key = None
         for stmt in stmt_fixture_one:
index 043e7e5a0a0fd39ddf7335450c093cab5f906450..501ea699e5781f309bb1d600eb7a261933e0e422 100644 (file)
@@ -1,15 +1,15 @@
 # /home/classic/dev/sqlalchemy/test/profiles.txt
 # This file is written out on a per-environment basis.
-# For each test in aaa_profiling, the corresponding function and 
+# For each test in aaa_profiling, the corresponding function and
 # environment is located within this file.  If it doesn't exist,
 # the test is skipped.
-# If a callcount does exist, it is compared to what we received. 
+# If a callcount does exist, it is compared to what we received.
 # assertions are raised if the counts do not match.
-# 
-# To add a new callcount test, apply the function_call_count 
-# decorator and re-run the tests using the --write-profiles 
+#
+# To add a new callcount test, apply the function_call_count
+# decorator and re-run the tests using the --write-profiles
 # option - this file will be rewritten including the new count.
-# 
+#
 
 # TEST: test.aaa_profiling.test_compiler.CompileTest.test_insert
 
@@ -138,10 +138,10 @@ test.aaa_profiling.test_compiler.CompileTest.test_update_whereclause 3.7_sqlite_
 
 # TEST: test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one
 
-test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one 2.7_sqlite_pysqlite_dbapiunicode_cextensions 4968
-test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one 2.7_sqlite_pysqlite_dbapiunicode_nocextensions 4968
-test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one 3.7_sqlite_pysqlite_dbapiunicode_cextensions 5173
-test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one 3.7_sqlite_pysqlite_dbapiunicode_nocextensions 5173
+test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one 2.7_sqlite_pysqlite_dbapiunicode_cextensions 4302
+test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one 2.7_sqlite_pysqlite_dbapiunicode_nocextensions 4302
+test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one 3.7_sqlite_pysqlite_dbapiunicode_cextensions 4903
+test.aaa_profiling.test_misc.CacheKeyTest.test_statement_one 3.7_sqlite_pysqlite_dbapiunicode_nocextensions 4903
 
 # TEST: test.aaa_profiling.test_misc.EnumTest.test_create_enum_from_pep_435_w_expensive_members