[Python-checkins] r68358 - in sandbox/trunk/io-c: _iobase.c _iomodule.h io.c
antoine.pitrou
python-checkins at python.org
Tue Jan 6 03:59:11 CET 2009
Author: antoine.pitrou
Date: Tue Jan 6 03:59:11 2009
New Revision: 68358
Log:
More interned strings.
Modified:
sandbox/trunk/io-c/_iobase.c
sandbox/trunk/io-c/_iomodule.h
sandbox/trunk/io-c/io.c
Modified: sandbox/trunk/io-c/_iobase.c
==============================================================================
--- sandbox/trunk/io-c/_iobase.c (original)
+++ sandbox/trunk/io-c/_iobase.c Tue Jan 6 03:59:11 2009
@@ -138,7 +138,7 @@
PyObject_SetAttrString(self, "__IOBase_closed", Py_True);
- res = PyObject_CallMethod(self, "flush", NULL);
+ res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
if (res == NULL) {
/* If flush() fails, just give up */
if (PyErr_ExceptionMatches(PyExc_IOError))
@@ -186,7 +186,7 @@
PyObject *
_PyIOBase_checkSeekable(PyObject *self, PyObject *unused)
{
- PyObject *res = PyObject_CallMethod(self, "seekable", NULL);
+ PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_seekable, NULL);
if (res == NULL)
return NULL;
if (res != Py_True) {
@@ -211,7 +211,7 @@
PyObject *
_PyIOBase_checkReadable(PyObject *self, PyObject *unused)
{
- PyObject *res = PyObject_CallMethod(self, "readable", NULL);
+ PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_readable, NULL);
if (res == NULL)
return NULL;
if (res != Py_True) {
@@ -236,7 +236,7 @@
PyObject *
_PyIOBase_checkWritable(PyObject *self, PyObject *unused)
{
- PyObject *res = PyObject_CallMethod(self, "writable", NULL);
+ PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_writable, NULL);
if (res == NULL)
return NULL;
if (res != Py_True) {
@@ -261,7 +261,7 @@
static PyObject *
IOBase_exit(PyObject *self, PyObject *args)
{
- return PyObject_CallMethod(self, "close", NULL);
+ return PyObject_CallMethodObjArgs(self, _PyIO_str_close, NULL);
}
/* Lower-level APIs */
@@ -399,7 +399,7 @@
static PyObject *
IOBase_iternext(PyObject *self)
{
- PyObject *line = PyObject_CallMethod(self, "readline", NULL);
+ PyObject *line = PyObject_CallMethodObjArgs(self, _PyIO_str_readline, NULL);
if (line == NULL)
return NULL;
@@ -498,7 +498,7 @@
break; /* Stop Iteration */
}
- res = PyObject_CallMethod(self, "write", "O", line);
+ res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL);
Py_DECREF(line);
if (res == NULL) {
Py_DECREF(iter);
@@ -627,11 +627,13 @@
if (n < 0)
return PyObject_CallMethod(self, "readall", NULL);
+ /* TODO: allocate a bytes object directly instead and manually construct
+ a writable memoryview pointing to it. */
b = PyByteArray_FromStringAndSize(NULL, n);
if (b == NULL)
return NULL;
- res = PyObject_CallMethod(self, "readinto", "O", b);
+ res = PyObject_CallMethodObjArgs(self, _PyIO_str_readinto, b, NULL);
if (res == NULL) {
Py_DECREF(b);
return NULL;
Modified: sandbox/trunk/io-c/_iomodule.h
==============================================================================
--- sandbox/trunk/io-c/_iomodule.h (original)
+++ sandbox/trunk/io-c/_iomodule.h Tue Jan 6 03:59:11 2009
@@ -58,6 +58,7 @@
extern PyObject *_PyIO_str_read;
extern PyObject *_PyIO_str_readable;
extern PyObject *_PyIO_str_readinto;
+extern PyObject *_PyIO_str_readline;
extern PyObject *_PyIO_str_seekable;
extern PyObject *_PyIO_str_tell;
extern PyObject *_PyIO_str_truncate;
Modified: sandbox/trunk/io-c/io.c
==============================================================================
--- sandbox/trunk/io-c/io.c (original)
+++ sandbox/trunk/io-c/io.c Tue Jan 6 03:59:11 2009
@@ -22,6 +22,7 @@
PyObject *_PyIO_str_read;
PyObject *_PyIO_str_readable;
PyObject *_PyIO_str_readinto;
+PyObject *_PyIO_str_readline;
PyObject *_PyIO_str_seekable;
PyObject *_PyIO_str_tell;
PyObject *_PyIO_str_truncate;
@@ -640,6 +641,8 @@
goto fail;
if (!(_PyIO_str_readinto = PyUnicode_InternFromString("readinto")))
goto fail;
+ if (!(_PyIO_str_readline = PyUnicode_InternFromString("readline")))
+ goto fail;
if (!(_PyIO_str_seekable = PyUnicode_InternFromString("seekable")))
goto fail;
if (!(_PyIO_str_tell = PyUnicode_InternFromString("tell")))
More information about the Python-checkins
mailing list