Warning: preg_grep(): Compilation failed: quantifier does not follow a repeatable item at offset 134 in /var/www/tg-me/post.php on line 75
Библиотека питониста | Python, Django, Flask | Telegram Webview: pyproglib/6486 -
Telegram Group & Telegram Channel
🔥 Что такое __slots__ в Python?

__slots__ — это специальный атрибут класса, который:
Оптимизирует потребление памяти за счёт отказа от __dict__
Ускоряет доступ к атрибутам
Запрещает добавление новых атрибутов, не прописанных в __slots__

Пример без __slots__
class Point:
def __init__(self, x: float, y: float) -> None:
self.x = x
self.y = y

def __str__(self) -> str:
#

point = Point(1.2, 3.4)


🔹 Минус: каждый объект хранит атрибуты в __dict__, что расходует память

Пример с __slots__
class Point:
__slots__ = ('x', 'y')

def __init__(self, x: float, y: float) -> None:
self.x = x
self.y = y

def __str__(self) -> str:
#

point = Point(1.2, 3.4)


🔹 Плюсы:
1. Экономия памяти
2. Ускорение доступа к атрибутам

Когда __slots__ НЕ стоит использовать?
Если нужно динамически добавлять атрибуты
Если используется __dict__

Статья: https://clc.to/QjMXpg
Использовали __slots__ в проектах?

Библиотека питониста #буст
👍13😢51🔥1



tg-me.com/pyproglib/6486
Create:
Last Update:

🔥 Что такое __slots__ в Python?

__slots__ — это специальный атрибут класса, который:
Оптимизирует потребление памяти за счёт отказа от __dict__
Ускоряет доступ к атрибутам
Запрещает добавление новых атрибутов, не прописанных в __slots__

Пример без __slots__

class Point:
def __init__(self, x: float, y: float) -> None:
self.x = x
self.y = y

def __str__(self) -> str:
#

point = Point(1.2, 3.4)


🔹 Минус: каждый объект хранит атрибуты в __dict__, что расходует память

Пример с __slots__
class Point:
__slots__ = ('x', 'y')

def __init__(self, x: float, y: float) -> None:
self.x = x
self.y = y

def __str__(self) -> str:
#

point = Point(1.2, 3.4)


🔹 Плюсы:
1. Экономия памяти
2. Ускорение доступа к атрибутам

Когда __slots__ НЕ стоит использовать?
Если нужно динамически добавлять атрибуты
Если используется __dict__

Статья: https://clc.to/QjMXpg
Использовали __slots__ в проектах?

Библиотека питониста #буст

BY Библиотека питониста | Python, Django, Flask




Share with your friend now:
tg-me.com/pyproglib/6486

View MORE
Open in Telegram


Библиотека питониста | Python Django Flask Telegram | DID YOU KNOW?

Date: |

Telegram auto-delete message, expiring invites, and more

elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.

Export WhatsApp stickers to Telegram on iPhone

You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.

Библиотека питониста | Python Django Flask from us


Telegram Библиотека питониста | Python, Django, Flask
FROM USA