diff options
author | Georg Brandl <georg@python.org> | 2006-12-19 20:50:34 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-12-19 20:50:34 (GMT) |
commit | 66a796e5ab8dd7bfc1fe05a830feb05acdab6f53 (patch) | |
tree | 5ce191f813c475bf54c6ab40ecaebb820327a213 /Python | |
parent | 376446dd4e30006c4d4ad09b4cbda8b07e9ce23a (diff) | |
download | cpython-66a796e5ab8dd7bfc1fe05a830feb05acdab6f53.zip cpython-66a796e5ab8dd7bfc1fe05a830feb05acdab6f53.tar.gz cpython-66a796e5ab8dd7bfc1fe05a830feb05acdab6f53.tar.bz2 |
Patch #1601678: move intern() to sys.intern().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 26 | ||||
-rw-r--r-- | Python/sysmodule.c | 27 |
2 files changed, 27 insertions, 26 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 73b0220..3e6d237 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1119,31 +1119,6 @@ Return the hexadecimal representation of an integer or long integer."); static PyObject * -builtin_intern(PyObject *self, PyObject *args) -{ - PyObject *s; - if (!PyArg_ParseTuple(args, "S:intern", &s)) - return NULL; - if (!PyString_CheckExact(s)) { - PyErr_SetString(PyExc_TypeError, - "can't intern subclass of string"); - return NULL; - } - Py_INCREF(s); - PyString_InternInPlace(&s); - return s; -} - -PyDoc_STRVAR(intern_doc, -"intern(string) -> string\n\ -\n\ -``Intern'' the given string. This enters the string in the (global)\n\ -table of interned strings whose purpose is to speed up dictionary lookups.\n\ -Return the string itself or the previously interned string object with the\n\ -same value."); - - -static PyObject * builtin_iter(PyObject *self, PyObject *args) { PyObject *v, *w = NULL; @@ -2069,7 +2044,6 @@ static PyMethodDef builtin_methods[] = { {"hash", builtin_hash, METH_O, hash_doc}, {"hex", builtin_hex, METH_O, hex_doc}, {"id", builtin_id, METH_O, id_doc}, - {"intern", builtin_intern, METH_VARARGS, intern_doc}, {"isinstance", builtin_isinstance, METH_VARARGS, isinstance_doc}, {"issubclass", builtin_issubclass, METH_VARARGS, issubclass_doc}, {"iter", builtin_iter, METH_VARARGS, iter_doc}, diff --git a/Python/sysmodule.c b/Python/sysmodule.c index b74a440..101a6e4 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -264,6 +264,32 @@ operating system filenames." #endif + +static PyObject * +sys_intern(PyObject *self, PyObject *args) +{ + PyObject *s; + if (!PyArg_ParseTuple(args, "S:intern", &s)) + return NULL; + if (!PyString_CheckExact(s)) { + PyErr_SetString(PyExc_TypeError, + "can't intern subclass of string"); + return NULL; + } + Py_INCREF(s); + PyString_InternInPlace(&s); + return s; +} + +PyDoc_STRVAR(intern_doc, +"intern(string) -> string\n\ +\n\ +``Intern'' the given string. This enters the string in the (global)\n\ +table of interned strings whose purpose is to speed up dictionary lookups.\n\ +Return the string itself or the previously interned string object with the\n\ +same value."); + + /* * Cached interned string objects used for calling the profile and * trace functions. Initialized by trace_init(). @@ -772,6 +798,7 @@ static PyMethodDef sys_methods[] = { {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, getwindowsversion_doc}, #endif /* MS_WINDOWS */ + {"intern", sys_intern, METH_VARARGS, intern_doc}, #ifdef USE_MALLOPT {"mdebug", sys_mdebug, METH_VARARGS}, #endif |