I have recently read the python-telegram-bot
docs that explains the advantages of arbitrary_callback_data
. I did not understand this sentence in the docs:
PTB stores the callback data objects in memory. Additionally, to that, it stores a mapping of CallbackQuery.id to the corresponding UUID. By default, both storages contain a maximum number of 1024 items.
What does 1024 represent? In my code I have some inline buttons that for example remove a document from Mongodb. Like the example below:
InlineKeyboardButton(text='title',callback_data=f'delete_doc_{the_id_of_doc}')
Does that mean for instance if I have millions of ids, It exceeds the limit that is set to 1024 by default? Because the callback_data
of each button in my code is unique.
The 1024 is the number of complete keyboards that are kept in memory. For each keyboard, the unique identifiers of the buttons plus the actualy data of the button are kept in memory.
Note that as long as delete_doc_{the_id_of_doc}
is shorter than 64 chars, there is maybe not much added benefit for you in using this feature.
Disclaimer: I'm currently the maintainer of python-telegram-bot
.