Repository navigation
Use Argument Clinic in sqlite3 #85128
Description
Activity
Use Argument Clinic in sqlite3.
- added3.10 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
on Jun 12, 2020 What's the purpose of using AC, did the change improve performance?
It can make hard to track the code history.The primary reason is that it will be provide easy access to module state.
The first step in making sqlite3 support multiphase init was to create heap types. The second step is argument clinic. The third will be to use AC for module state. The last step will then be final multiphase support.
Also, IMHO, AC greatly improves the body of methods (readability => maintainability, hardened parsing of arguments)
Also, see the comment from Victor here: #22478 (comment)
Also, see the comment from Victor here: #22478 (comment)
Okay got it
By the way, what's the preferred way to benchmark performance?
Thank you erlendaasland for working on #66674.
This time was a good time to review my AC knowledge ;)Thank you erlendaasland for working on #66674.
… and thank you for taking the time to review this!
#68195 introduced a regression:
>>> import sqlite3 >>> help(sqlite3) Traceback (most recent call last): File "Lib/inspect.py", line 2049, in wrap_value value = eval(s, module_dict) File "<string>", line 1, in <module> NameError: name 'cursor' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "Lib/inspect.py", line 2052, in wrap_value value = eval(s, sys_module_dict) File "<string>", line 1, in <module> NameError: name 'cursor' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "Lib/_sitebuiltins.py", line 103, in __call__ return pydoc.help(*args, **kwds) File "Lib/pydoc.py", line 2000, in __call__ self.help(request) File "Lib/pydoc.py", line 2059, in help else: doc(request, 'Help on %s:', output=self._output) File "Lib/pydoc.py", line 1779, in doc pager(render_doc(thing, title, forceload)) File "Lib/pydoc.py", line 1772, in render_doc return title % desc + '\n\n' + renderer.document(object, name) File "Lib/pydoc.py", line 472, in document if inspect.ismodule(object): return self.docmodule(*args) File "Lib/pydoc.py", line 1267, in docmodule contents.append(self.document(value, key, name)) File "Lib/pydoc.py", line 473, in document if inspect.isclass(object): return self.docclass(*args) File "Lib/pydoc.py", line 1433, in docclass attrs = spill("Methods %s:\n" % tag, attrs, File "Lib/pydoc.py", line 1382, in spill push(self.document(value, File "Lib/pydoc.py", line 474, in document if inspect.isroutine(object): return self.docroutine(*args) File "Lib/pydoc.py", line 1492, in docroutine signature = inspect.signature(object) File "Lib/inspect.py", line 3129, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped, File "Lib/inspect.py", line 2877, in from_callable return _signature_from_callable(obj, sigcls=cls, File "Lib/inspect.py", line 2351, in _signature_from_callable return _signature_from_builtin(sigcls, obj, File "Lib/inspect.py", line 2164, in _signature_from_builtin return _signature_fromstr(cls, func, s, skip_bound_arg) File "Lib/inspect.py", line 2102, in _signature_fromstr p(name, default) File "Lib/inspect.py", line 2084, in p default_node = RewriteSymbolics().visit(default_node) File "Lib/ast.py", line 410, in visit return visitor(node) File "Lib/inspect.py", line 2071, in visit_Attribute return wrap_value(value) File "Lib/inspect.py", line 2054, in wrap_value raise RuntimeError() RuntimeError
Looks like this is the culprit:
cpython/Modules/_sqlite/cursor.c
Line 825 in 2396614
size as maxrows: int(c_default='self->arraysize') = cursor.arraysize I don't see how to easily solve this in AC: we want the arraysize of the cursor instance, but I don't see how I'm going to get this via the AC namespace/context. Using a "bogus" default value works:
size as maxrows: int(c_default='self->arraysize') = 1
Is there a better way?
Use NULL.
Thanks, but I prefer the following:
size as maxrows: int(c_default='self->arraysize', py_default='<unrepresentable>') = 1
Erlend, is anything left in this issue?
Erlend, is anything left in this issue?
Nothing left; thank you for your guidance and reviews, Dong-hee, Berker, Serhiy, and Pablo.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: