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
4958f714
Kaydet (Commit)
4958f714
authored
Tem 15, 2013
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
- Issue #18440: Clarify that `hash()` can truncate the value returned from an
object's custom `__hash__()` method.
üst
0fedb37c
224a599c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
8 deletions
+27
-8
functions.rst
Doc/library/functions.rst
+9
-4
datamodel.rst
Doc/reference/datamodel.rst
+15
-4
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/functions.rst
Dosyayı görüntüle @
4958f714
...
...
@@ -587,11 +587,16 @@ are always available. They are listed here in alphabetical order.
.. function:: hash(object)
Return the hash value of the object (if it has one). Hash values are
integers.
They are used to quickly compare dictionary keys during a dictionary lookup.
Numeric values that compare equal have the same hash value (even if they are of
different types, as is the case for 1 and 1.0).
Return the hash value of the object (if it has one). Hash values are
integers. They are used to quickly compare dictionary keys during a
dictionary lookup. Numeric values that compare equal have the same hash
value (even if they are of
different types, as is the case for 1 and 1.0).
.. note::
For object's with custom :meth:`__hash__` methods, note that :func:`hash`
truncates the return value based on the bit width of the host machine.
See :meth:`__hash__` for details.
.. function:: help([object])
...
...
Doc/reference/datamodel.rst
Dosyayı görüntüle @
4958f714
...
...
@@ -1264,10 +1264,21 @@ Basic customization
Called by built-in function :func:`hash` and for operations on members of
hashed collections including :class:`set`, :class:`frozenset`, and
:class:`dict`. :meth:`__hash__` should return an integer. The only required
property is that objects which compare equal have the same hash value; it is
advised to somehow mix together (e.g. using exclusive or) the hash values for
the components of the object that also play a part in comparison of objects.
:class:`dict`. :meth:`__hash__` should return an integer. The only
required property is that objects which compare equal have the same hash
value; it is advised to somehow mix together (e.g. using exclusive or) the
hash values for the components of the object that also play a part in
comparison of objects.
.. note::
:func:`hash` truncates the value returned from an object's custom
:meth:`__hash__` method to the size of a :c:type:`Py_ssize_t`. This is
typically 8 bytes on 64-bit builds and 4 bytes on 32-bit builds. If an
object's :meth:`__hash__` must interoperate on builds of different bit
sizes, be sure to check the width on all supported builds. An easy way
to do this is with
``python -c "import sys; print(sys.hash_info.width)"``
If a class does not define an :meth:`__eq__` method it should not define a
:meth:`__hash__` operation either; if it defines :meth:`__eq__` but not
...
...
Misc/NEWS
Dosyayı görüntüle @
4958f714
...
...
@@ -581,6 +581,9 @@ Tests
Documentation
-------------
- Issue #18440: Clarify that `hash()` can truncate the value returned from an
object'
s
custom
`
__hash__
()`
method
.
-
Issue
#
17844
:
Add
links
to
encoders
and
decoders
for
bytes
-
to
-
bytes
codecs
.
-
Issue
#
14097
:
improve
the
"introduction"
page
of
the
tutorial
.
...
...
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