Может показаться, что ответ = 1, т.к. hash любого инстанса класса Some равен 1.
1) При добавлении нового элемента в set, dict питон находит его hash(element) (если вы не знаете, что такое хэш функция и зачем она нужна, почитайте про хэш таблицы).
2) Из этого хэша определяется индекс в массиве, куда нужно вставить этот элемент.
3) Если по этому индексу ничего нет, то элемент просто вставляется.
4) А если там уже есть какой-то элемент (это коллизия), то питон уже сравнивает существуещий элемент с тем, который хотим добавить (new == old). Если они равны, то старый заменяется новым элементом.
5) В нашем случае все экземпляры Some разные, т.к.
Может показаться, что ответ = 1, т.к. hash любого инстанса класса Some равен 1.
1) При добавлении нового элемента в set, dict питон находит его hash(element) (если вы не знаете, что такое хэш функция и зачем она нужна, почитайте про хэш таблицы).
2) Из этого хэша определяется индекс в массиве, куда нужно вставить этот элемент.
3) Если по этому индексу ничего нет, то элемент просто вставляется.
4) А если там уже есть какой-то элемент (это коллизия), то питон уже сравнивает существуещий элемент с тем, который хотим добавить (new == old). Если они равны, то старый заменяется новым элементом.
5) В нашем случае все экземпляры Some разные, т.к.
__eq__ всегда возвращает False
Поэтому ответ 5.
#set #dict #hash
BY PyThrone
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Tata Power whose core business is to generate, transmit and distribute electricity has made no money to investors in the last one decade. That is a big blunder considering it is one of the largest power generation companies in the country. One of the reasons is the company's huge debt levels which stood at ₹43,559 crore at the end of March 2021 compared to the company’s market capitalisation of ₹44,447 crore.
Telegram and Signal Havens for Right-Wing Extremists
Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.