When implementing the function, __eq__I was interested to know if I need to test the identification using the keyword is. Testing equality for two different variables can be immediately evaluated by the Truefunction iswhen the variables point to the same instance of the object. If the variables point to different instances, further testing is, of course, necessary. Let's say we have it S = U, and obviously we want it to S == Ureturn True, and identity testing will speed it up.
__eq__
is
True
S = U
S == U
def __eq__(self, other): if self is other: return True else: pass # do another user defined test for equality
, , , - . Python , in list s; C ( CPython), Python:
in
list
any(element is target or element == target for element in lst)
, , , , numpy.NAN is numpy.NAN - True, numpy.NAN == numpy.NAN - False. , , .
numpy.NAN is numpy.NAN
numpy.NAN == numpy.NAN
False
Source: https://habr.com/ru/post/1695210/More articles:How can I add .attr ('colspan', '100') dynamically if there is only one visible table cell per row? - jqueryAWS EC2 instance cannot connect to bitbucket.org - gitСохранить изображение с холста постоянно на сервер - javascriptAjax causes 419 error return despite the correct token in Laravel - phpPrevent users from submitting their own image using ajax? - javascriptКак просмотреть структуру файла класса в IntelliJ без открытия фактического файла класса? - javaMigrations Activerecord, what makes t.references correctly point to a custom identifier type, string not integer? - ruby | fooobar.comMaven build plugin: the descriptorRef does not use basedir - mavenShow which files have been changed in any SVN branch, but have not yet merged with the trunk - branchС#: как установить выполнение хранимой процедуры с помощью parallelism или улучшить время выполнения? - c#All Articles