Mercurial > cpython-lru_cache-weakref
diff Modules/arraymodule.c @ 72835:5e33219492bc
Add API for static strings, primarily good for identifiers.
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sun, 09 Oct 2011 10:38:36 +0200 |
| parents | e88fc377f961 |
| children | 81380082d216 |
line wrap: on
line diff
--- a/Modules/arraymodule.c Sun Oct 09 08:58:16 2011 +0200 +++ b/Modules/arraymodule.c Sun Oct 09 10:38:36 2011 +0200 @@ -1253,6 +1253,7 @@ PyObject *f, *b, *res; Py_ssize_t itemsize = self->ob_descr->itemsize; Py_ssize_t n, nbytes; + _Py_identifier(read); int not_enough_bytes; if (!PyArg_ParseTuple(args, "On:fromfile", &f, &n)) @@ -1264,7 +1265,7 @@ return NULL; } - b = PyObject_CallMethod(f, "read", "n", nbytes); + b = _PyObject_CallMethodId(f, &PyId_read, "n", nbytes); if (b == NULL) return NULL; @@ -1321,12 +1322,14 @@ char* ptr = self->ob_item + i*BLOCKSIZE; Py_ssize_t size = BLOCKSIZE; PyObject *bytes, *res; + _Py_identifier(write); + if (i*BLOCKSIZE + size > nbytes) size = nbytes - i*BLOCKSIZE; bytes = PyBytes_FromStringAndSize(ptr, size); if (bytes == NULL) return NULL; - res = PyObject_CallMethod(f, "write", "O", bytes); + res = _PyObject_CallMethodId(f, &PyId_write, "O", bytes); Py_DECREF(bytes); if (res == NULL) return NULL;
