[Python-checkins] r52366 - sandbox/trunk/import_in_py/importer.py
brett.cannon
python-checkins at python.org
Tue Oct 17 21:38:39 CEST 2006
Author: brett.cannon
Date: Tue Oct 17 21:38:39 2006
New Revision: 52366
Modified:
sandbox/trunk/import_in_py/importer.py
Log:
Note how one could implement a sqlite3 back-end.
Modified: sandbox/trunk/import_in_py/importer.py
==============================================================================
--- sandbox/trunk/import_in_py/importer.py (original)
+++ sandbox/trunk/import_in_py/importer.py Tue Oct 17 21:38:39 2006
@@ -60,10 +60,54 @@
+ XXX
sqlite3 importer use-case:
-* Simple way
- + XXX
+* Simple way (only support just bytecode or source)
+ + DB
+ - For source just a column for module name and another containing the
+ source.
+ - For bytecode, a column for module name, another containing .pyc
+ output.
+ + Importer
+ - Query DB to see if module name is there.
+ + Loader
+ - Read entry in DB for module into a StringIO instance.
+ - Set 'name' attribute on StringIO instance to be DB path plus module name.
+ + Use the py/pyc file handler set for just source or bytecode.
* Feature-rich way
- + XXX
+ + DB
+ - Module name.
+ - Source code.
+ - Marshalled code of the source.
+ * Set to NULL when source code is modified, which removes need of
+ storing the bytecode's timestamp.
+ - Magic number for bytecode.
+ + Importer
+ - Query DB to see if module is listed.
+ - Whether it is in bytecode or source form is irrelevant.
+ + Loader
+ - See if bytecode is in DB; if so then have that used, otherwise source.
+ - Pass in tuple of DB instance and requested module.
+ + Subclass PyPycBaseHandler
+ - Have both source and bytecode opaque objects be a tuple of the DB
+ instance and the module name that is being handled.
+ - get_bytecode()
+ * Reads DB and returns magic number, 0 for timestamp, and bytecode.
+ * Timestamp is unneeded as existence of bytecode implicitly means
+ that it is not outdated.
+ - find_source()
+ * Can return same tuple as passed into handle_code().
+ - verify_timestamp()
+ * ``return True``.
+ - get_code_from_source()
+ * Get source from DB.
+ * compile.
+ * return code object and 0 for timestamp.
+ - write_bytecode()
+ * Get marshalled string from code object.
+ * Write marshalled string to DB.
+ * Write current magic number to DB.
+ - get_location()
+ * Return the path to the DB and the module name.
+ * Could even return SQL statement to get module if one cared.
"""
from __future__ import with_statement
More information about the Python-checkins
mailing list