Added intern() function.

This commit is contained in:
Guido van Rossum 1997-02-14 15:48:05 +00:00
parent 17ca992818
commit e8811f85ed
1 changed files with 14 additions and 0 deletions

View File

@ -840,6 +840,19 @@ builtin_input(self, args)
return res; return res;
} }
static PyObject *
builtin_intern(self, args)
PyObject *self;
PyObject *args;
{
PyObject *s;
if (!PyArg_ParseTuple(args, "S", &s))
return NULL;
Py_INCREF(s);
PyString_InternInPlace(&s);
return s;
}
static object * static object *
builtin_int(self, args) builtin_int(self, args)
object *self; object *self;
@ -1558,6 +1571,7 @@ static struct methodlist builtin_methods[] = {
{"hex", builtin_hex, 1}, {"hex", builtin_hex, 1},
{"id", builtin_id, 1}, {"id", builtin_id, 1},
{"input", builtin_input, 1}, {"input", builtin_input, 1},
{"intern", builtin_intern, 1},
{"int", builtin_int, 1}, {"int", builtin_int, 1},
{"len", builtin_len, 1}, {"len", builtin_len, 1},
{"list", builtin_list, 1}, {"list", builtin_list, 1},