If I want to get a bot with an ID, which is faster between:
storage = {
'bots': [
{ 'id': 123, 'auth': '81792367' },
{ 'id': 345, 'auth': '86908472' },
{ 'id': 543, 'auth': '12343321' }
]
}
id = 345
bot = next(bot['auth'] for bot in storage['bots'] if bot['id'] == id)
and
storage = {
'bots': {
123: '81792367',
345: '86908472',
543: '12343321',
}
}
id = 345
bot = storage['bots'][id]
and which must be used for the Python pep8 or most beautiful?