Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c8555b38
Kaydet (Commit)
c8555b38
authored
May 22, 2001
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Iterator support: made the xreadlines object its own iterator. This
ought to be faster.
üst
6626c1f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
25 deletions
+81
-25
xreadlinesmodule.c
Modules/xreadlinesmodule.c
+81
-25
No files found.
Modules/xreadlinesmodule.c
Dosyayı görüntüle @
c8555b38
...
@@ -54,13 +54,8 @@ xreadlines(PyObject *self, PyObject *args)
...
@@ -54,13 +54,8 @@ xreadlines(PyObject *self, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
xreadlines_
item
(
PyXReadlinesObject
*
a
,
int
i
)
xreadlines_
common
(
PyXReadlinesObject
*
a
)
{
{
if
(
i
!=
a
->
abslineno
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"xreadlines object accessed out of order"
);
return
NULL
;
}
if
(
a
->
lineno
>=
a
->
lineslen
)
{
if
(
a
->
lineno
>=
a
->
lineslen
)
{
Py_XDECREF
(
a
->
lines
);
Py_XDECREF
(
a
->
lines
);
a
->
lines
=
PyObject_CallMethod
(
a
->
file
,
"readlines"
,
"(i)"
,
a
->
lines
=
PyObject_CallMethod
(
a
->
file
,
"readlines"
,
"(i)"
,
...
@@ -75,6 +70,61 @@ xreadlines_item(PyXReadlinesObject *a, int i)
...
@@ -75,6 +70,61 @@ xreadlines_item(PyXReadlinesObject *a, int i)
return
PySequence_GetItem
(
a
->
lines
,
a
->
lineno
++
);
return
PySequence_GetItem
(
a
->
lines
,
a
->
lineno
++
);
}
}
static
PyObject
*
xreadlines_item
(
PyXReadlinesObject
*
a
,
int
i
)
{
if
(
i
!=
a
->
abslineno
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"xreadlines object accessed out of order"
);
return
NULL
;
}
return
xreadlines_common
(
a
);
}
static
PyObject
*
xreadlines_getiter
(
PyXReadlinesObject
*
a
)
{
Py_INCREF
(
a
);
return
(
PyObject
*
)
a
;
}
static
PyObject
*
xreadlines_iternext
(
PyXReadlinesObject
*
a
)
{
PyObject
*
res
;
res
=
xreadlines_common
(
a
);
if
(
res
==
NULL
&&
PyErr_ExceptionMatches
(
PyExc_IndexError
))
PyErr_Clear
();
return
res
;
}
static
PyObject
*
xreadlines_next
(
PyXReadlinesObject
*
a
,
PyObject
*
args
)
{
PyObject
*
res
;
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
res
=
xreadlines_common
(
a
);
if
(
res
==
NULL
&&
PyErr_ExceptionMatches
(
PyExc_IndexError
))
PyErr_SetObject
(
PyExc_StopIteration
,
Py_None
);
return
res
;
}
static
char
next_doc
[]
=
"x.next() -> the next line or raise StopIteration"
;
static
PyMethodDef
xreadlines_methods
[]
=
{
{
"next"
,
(
PyCFunction
)
xreadlines_next
,
METH_VARARGS
,
next_doc
},
{
NULL
,
NULL
}
};
static
PyObject
*
xreadlines_getattr
(
PyObject
*
a
,
char
*
name
)
{
return
Py_FindMethod
(
xreadlines_methods
,
a
,
name
);
}
static
PySequenceMethods
xreadlines_as_sequence
=
{
static
PySequenceMethods
xreadlines_as_sequence
=
{
0
,
/*sq_length*/
0
,
/*sq_length*/
0
,
/*sq_concat*/
0
,
/*sq_concat*/
...
@@ -88,26 +138,32 @@ static PyTypeObject XReadlinesObject_Type = {
...
@@ -88,26 +138,32 @@ static PyTypeObject XReadlinesObject_Type = {
"xreadlines"
,
"xreadlines"
,
sizeof
(
PyXReadlinesObject
)
+
PyGC_HEAD_SIZE
,
sizeof
(
PyXReadlinesObject
)
+
PyGC_HEAD_SIZE
,
0
,
0
,
(
destructor
)
xreadlines_dealloc
,
/*tp_dealloc*/
(
destructor
)
xreadlines_dealloc
,
/* tp_dealloc */
0
,
/*tp_print*/
0
,
/* tp_print */
0
,
/*tp_getattr*/
xreadlines_getattr
,
/* tp_getattr */
0
,
/*tp_setattr*/
0
,
/* tp_setattr */
0
,
/*tp_compare*/
0
,
/* tp_compare */
0
,
/*tp_repr*/
0
,
/* tp_repr */
0
,
/*tp_as_number*/
0
,
/* tp_as_number */
&
xreadlines_as_sequence
,
/*tp_as_sequence*/
&
xreadlines_as_sequence
,
/* tp_as_sequence */
0
,
/*tp_as_mapping*/
0
,
/* tp_as_mapping */
0
,
/*tp_hash*/
0
,
/* tp_hash */
0
,
/*tp_call*/
0
,
/* tp_call */
0
,
/*tp_str*/
0
,
/* tp_str */
0
,
/*tp_getattro*/
0
,
/* tp_getattro */
0
,
/*tp_setattro*/
0
,
/* tp_setattro */
0
,
/*tp_as_buffer*/
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
,
/*tp_flags*/
Py_TPFLAGS_DEFAULT
,
/* tp_flags */
0
,
/* tp_doc */
0
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
(
getiterfunc
)
xreadlines_getiter
,
/* tp_iter */
(
iternextfunc
)
xreadlines_iternext
,
/* tp_iternext */
};
};
static
PyMethodDef
xreadlines_
method
s
[]
=
{
static
PyMethodDef
xreadlines_
function
s
[]
=
{
{
"xreadlines"
,
xreadlines
,
METH_VARARGS
,
xreadlines_doc
},
{
"xreadlines"
,
xreadlines
,
METH_VARARGS
,
xreadlines_doc
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -118,5 +174,5 @@ initxreadlines(void)
...
@@ -118,5 +174,5 @@ initxreadlines(void)
PyObject
*
m
;
PyObject
*
m
;
XReadlinesObject_Type
.
ob_type
=
&
PyType_Type
;
XReadlinesObject_Type
.
ob_type
=
&
PyType_Type
;
m
=
Py_InitModule
(
"xreadlines"
,
xreadlines_
method
s
);
m
=
Py_InitModule
(
"xreadlines"
,
xreadlines_
function
s
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment