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
224c87d6
Kaydet (Commit)
224c87d6
authored
Eki 02, 2013
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #18594: Fix the fallback path in collections.Counter().
üst
1a33b2f3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
19 deletions
+25
-19
NEWS
Misc/NEWS
+2
-1
_collectionsmodule.c
Modules/_collectionsmodule.c
+23
-18
No files found.
Misc/NEWS
Dosyayı görüntüle @
224c87d6
...
...
@@ -79,7 +79,8 @@ Library
when necessary. Patch by Oscar Benjamin.
- Issue #18594: The fast path for collections.Counter() was never taken
due to an over-restrictive type check.
due to an over-restrictive type check. And the fallback path did
not implement the same algorithm as the pure python code.
- Properly initialize all fields of a SSL object after allocation.
...
...
Modules/_collectionsmodule.c
Dosyayı görüntüle @
224c87d6
...
...
@@ -1694,7 +1694,9 @@ _count_elements(PyObject *self, PyObject *args)
PyObject
*
it
,
*
iterable
,
*
mapping
,
*
oldval
;
PyObject
*
newval
=
NULL
;
PyObject
*
key
=
NULL
;
PyObject
*
zero
=
NULL
;
PyObject
*
one
=
NULL
;
PyObject
*
mapping_get
=
NULL
;
PyObject
*
mapping_getitem
;
PyObject
*
mapping_setitem
;
PyObject
*
dict_getitem
;
...
...
@@ -1708,10 +1710,8 @@ _count_elements(PyObject *self, PyObject *args)
return
NULL
;
one
=
PyLong_FromLong
(
1
);
if
(
one
==
NULL
)
{
Py_DECREF
(
it
);
return
NULL
;
}
if
(
one
==
NULL
)
goto
done
;
mapping_getitem
=
_PyType_LookupId
(
Py_TYPE
(
mapping
),
&
PyId___getitem__
);
dict_getitem
=
_PyType_LookupId
(
&
PyDict_Type
,
&
PyId___getitem__
);
...
...
@@ -1741,23 +1741,25 @@ _count_elements(PyObject *self, PyObject *args)
Py_DECREF
(
key
);
}
}
else
{
mapping_get
=
PyObject_GetAttrString
(
mapping
,
"get"
);
if
(
mapping_get
==
NULL
)
goto
done
;
zero
=
PyLong_FromLong
(
0
);
if
(
zero
==
NULL
)
goto
done
;
while
(
1
)
{
key
=
PyIter_Next
(
it
);
if
(
key
==
NULL
)
break
;
oldval
=
PyObject_GetItem
(
mapping
,
key
);
if
(
oldval
==
NULL
)
{
if
(
!
PyErr_Occurred
()
||
!
PyErr_ExceptionMatches
(
PyExc_KeyError
))
break
;
PyErr_Clear
();
Py_INCREF
(
one
);
newval
=
one
;
}
else
{
newval
=
PyNumber_Add
(
oldval
,
one
);
Py_DECREF
(
oldval
);
if
(
newval
==
NULL
)
break
;
}
oldval
=
PyObject_CallFunctionObjArgs
(
mapping_get
,
key
,
zero
,
NULL
);
if
(
oldval
==
NULL
)
break
;
newval
=
PyNumber_Add
(
oldval
,
one
);
Py_DECREF
(
oldval
);
if
(
newval
==
NULL
)
break
;
if
(
PyObject_SetItem
(
mapping
,
key
,
newval
)
==
-
1
)
break
;
Py_CLEAR
(
newval
);
...
...
@@ -1765,10 +1767,13 @@ _count_elements(PyObject *self, PyObject *args)
}
}
done:
Py_DECREF
(
it
);
Py_XDECREF
(
key
);
Py_XDECREF
(
newval
);
Py_DECREF
(
one
);
Py_XDECREF
(
mapping_get
);
Py_XDECREF
(
zero
);
Py_XDECREF
(
one
);
if
(
PyErr_Occurred
())
return
NULL
;
Py_RETURN_NONE
;
...
...
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