[Python-checkins] r53420 - in python/trunk: Lib/sqlite3/dbapi2.py Lib/sqlite3/test/factory.py Lib/sqlite3/test/regression.py Lib/sqlite3/test/types.py Modules/_sqlite/cache.c Modules/_sqlite/cache.h Modules/_sqlite/connection.c Modules/_sqlite/connection.h Modules/_sqlite/cursor.c Modules/_sqlite/cursor.h Modules/_sqlite/microprotocols.c Modules/_sqlite/microprotocols.h Modules/_sqlite/module.c Modules/_sqlite/module.h Modules/_sqlite/prepare_protocol.c Modules/_sqlite/prepare_protocol.h Modules/_sqlite/row.c Modules/_sqlite/row.h Modules/_sqlite/statement.c Modules/_sqlite/statement.h Modules/_sqlite/util.c Modules/_sqlite/util.h

"Martin v. Löwis" martin at v.loewis.de
Mon Jan 15 09:08:09 CET 2007


Gerhard Häring schrieb:
>> The right reaction should have been to make more symbols static; that
>> includes cache_init. Static symbols don't conflict dynamically. They
>> are guaranteed to be visible only in the translation unit (i.e. C file)
>> where they are defined.
>> Unfortunately, I have a lot of cross-translation-unit calls in the sqlite3
> module. That's because basically for each object (Connection, Cursor,
> Cache, Statement) there is a separate .c and .h file. The functions that
> set up the types (like cache_init) are all called from the module file
> module.c.

That's not true. Only microprotocols_init and converters_init are called
from module.c. cache_init is only referred-to in cache.c, as the init
proc of CacheType (it is not a module initialization routine).
Likewise, new_node, node_dealloc, cache_dealloc, cache_display,
NodeType, connection_init, flush_statement_cache, reset_all_statements,
connection_dealloc, connection_close, connection_rollback, set_result,
func_callback, step_callback, _drop_unused_statement_references,
connection_create_aggregate, _authorizer_callback,
connection_set_authorizer, connection_call, connection_execute,
connection_executemany, connection_executescript, and more,
could all be static.
connection_get_isolation_level, connection_get_total_changes,
connection_set_isolation_level, collation_callback,
connection_interrupt, connection_create_collation, and more,
are already static, so there was no need to rename them.
The single call to cache_get in cursor.c *should* be eliminated:
cache_get is declared as a METH_O method, yet cursor.c seems to
call it with an argument tuple. It would be better called as
 PyObject_CallMethod(self->connection->statement_cache, "get",
 "O", operation);
Using the same mechanism, connection_commit could become static
(although the two calls to it seem to be correct).
I reviewed these changes only up to cursor.c, so if you revise
this change, you should find out what additional changes can be undone
in cursor.c, prepare_protocol.c, row.c, etc.
Regards,
Martin


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /