[issue19230] Reimplement the keyword module in C

STINNER Victor report at bugs.python.org
Sat Oct 12 02:33:11 CEST 2013


New submission from STINNER Victor:

To speedup Python startup, I propose to reimplement the keyword module in C. Attached patch implements it.

* Remove Lib/keyword.py
* Add Tools/scripts/keyword.py: script to build Modules/keyword.h
* The new module is Modules/keyword.c

I chose to change the keyword.kwlist type from list to tuple. The documentation only says they that kwlist is a "Sequence":
http://docs.python.org/dev/library/keyword.html#keyword.kwlist

The keyword is now used by the collections module in the implementation of namedtuple.

The keyword module is trivial: it only contains a sequence of strings and a method checking if a string is part of this sequence. It would be simpler to add this to an existing module. I suppose that a new module was added for technical reasons.

----------
files: keyword.patch
keywords: patch
messages: 199528
nosy: christian.heimes, haypo, pitrou
priority: normal
severity: normal
status: open
title: Reimplement the keyword module in C
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file32054/keyword.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19230>
_______________________________________


More information about the Python-bugs-list mailing list