Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8811f8

Browse files
committed
Added intern() function.
1 parent 17ca992 commit e8811f8

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Python/bltinmodule.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,19 @@ builtin_input(self, args)
840840
return res;
841841
}
842842

843+
static PyObject *
844+
builtin_intern(self, args)
845+
PyObject *self;
846+
PyObject *args;
847+
{
848+
PyObject *s;
849+
if (!PyArg_ParseTuple(args, "S", &s))
850+
return NULL;
851+
Py_INCREF(s);
852+
PyString_InternInPlace(&s);
853+
return s;
854+
}
855+
843856
static object *
844857
builtin_int(self, args)
845858
object *self;
@@ -1558,6 +1571,7 @@ static struct methodlist builtin_methods[] = {
15581571
{"hex", builtin_hex, 1},
15591572
{"id", builtin_id, 1},
15601573
{"input", builtin_input, 1},
1574+
{"intern", builtin_intern, 1},
15611575
{"int", builtin_int, 1},
15621576
{"len", builtin_len, 1},
15631577
{"list", builtin_list, 1},

0 commit comments

Comments
 (0)