Sly32

Рейтинг
370
Регистрация
29.03.2012
danforth:
Че-то быстро ты, а я хотел задачки по сложнее закинуть, не хочешь?

Создавай тему, почему бы и нет

Danforth:
Che's something you quickly, and I would like puzzles on the harder to throw, do you want?

Create a theme, why not?

danforth:
Ну и опять таки, ты не скинул весь файл с кодом


data = [ {'id': 0, 'media_category': 'clip'},
{'id': 1, 'media_category': 'promo'},
{'id': 2, 'media_category': 'promo'},
{'id': 3, 'meda_category': 'promo'},
{'id': 4, 'media_category': 'clip'}]


def filter_data(data):
return filter(lambda _data: _data.get('media_category') not in ['promo'], data)


result = filter_data(data)
for item in result:
print(item)

собственно, сам код - строки 9-10, остальное - чтобы проверить в любой питоновской консоли. В рамках задачи мне потребовалось вставить 2 строки в существующий код - проверка на ключ, что нужно фильтровать и сама фильтрация.

Про скорость - понятно что го будет быстрее, но все это компилируется в сpython в реальности, там уже несильно важно.

Дв а принципе, я ничего не имею против кода на пхп, это не тема для срача)

Спасибо всем за участие, будете у нас в Минске - с удовольствием пересекусь за пивом. Думаю тема исчерпана

Danforth:
Well, again, you're not thrown off the whole code file


data = [ { 'Id': 0, 'media_category': 'clip'},
{ 'Id': 1, 'media_category': 'promo'},
{ 'Id': 2, 'media_category': 'promo'},
{ 'Id': 3, 'meda_category': 'promo'},
{ 'Id': 4, 'media_category': 'clip'}]


def filter_data (data):
return filter (lambda _data: _data.get ( 'media_category') not in [ 'promo'], data)


result = filter_data (data)
for item in result:
print (item)

in fact, the code itself - lines 9-10, the rest - to check any pitonovskoj console. As part of the task, I need to insert 2 lines to the existing code - a key check, you need to filter and filtering itself.

About speed - it is clear that the first will be faster, but it is compiled into spython in reality, there has not much important.

Dve and principle, I have nothing against the code on php, this is not a topic for sracha)

Thank you all for your participation, we will have in Minsk - happy Crossing for a beer. I think the topic is exhausted

tommy-gung:
но короткий же != самый быстрый?

Проверь, если есть сомнения)

tommy-gung:
but also short! = is the fastest?

Check, if in doubt)

ArbNet:
Это вы наивный Я несколько месяцев своей жизни на это потратил, и ещё может потрачу. Конечно будут пользоваться Посмотрел бы я на вас когда сделаете что-то уникальное, что превосходит существующие продукты.

Буду только рад за тебя, если получится. Просто пока что все, кроме тебя видят, что ты занимаешься ерундой. Твои решения ничего не дают ни в плане простоты, скорости, универсальности. да ты и сам не понимаешь, к чему стремишься)

ArbNet:
It's you I'm naive a few months of his life spent on it, and can spend more. Certainly will use I would look at you when to do something unique, which is higher than existing products.

I will be glad for you, if possible. Just as long as everything, but you can see that you are doing nonsense. Your solutions do not give any terms of simplicity, speed, versatility. but you yourself do not know, something to strive for)

Gerga:
Лучше как можно раньше отсечь ненужные данные...

Бесспорно, лучше. Но есть бизнес-логика и в ее рамках не всегда получается

Ну вот пример пример в данном случае, попробую обьяснить, почему это невыгодно делать на уровне БД. Запрос в постгресс делается 1 раз, потом данные храняться в редисе и в разных кейсах мне нужно получать разные итоговые данные. Задача - лишь один из них. Мне не нужно каждый раз стучаться в БД, я работаю с уже полученной коллекцией.

Поэтому и нужно решать средствами языка а не рассуждать - как еще это можно сделать.

tommy-gung:
вот решение от непрограммистов))

Мне неинтересно что есть в гугле - мне было интересно предложить народу поиграться с чем-то больше чем настраивать плагины. Тот кто умеет мыслить - включился и предложил решения, болтуны начали рассуждать...

по итогу - код на питоне - самый короткий и читабельный)

Тем кто отвечал по существу - спасибо за интересную дискуссию)

---------- Добавлено 14.06.2020 в 13:24 ----------

timo-71:
Да ладно, шутит наверное.

Важная, но я не говорил что сложная или для сеньоров - так, развлечься. Я например, потратил гораздо больше времени на написание тестов чем на саму задачу)

Gerga:
Better as soon as possible to cut off the unnecessary data ...

Undoubtedly, the better. But there is business logic, and within it is not always possible

Well, that's an example of an example in this case, I will try to explain why it is not profitable to do at the database level. Request to postgress done 1 time, then the data stored in the radishes and various case studies I need to get different totals. The task - only one of them. I do not need every time to knock in the database, I am working with the already received collection.

Therefore it is necessary to solve by means of language and not talk - how else to do it.

tommy-gung:
here is the solution of the non-programmers))

I'm not interested in what is in Google - it was interesting to offer people to play with something more than customize plugins. Anyone who knows how to think - was involved and suggested solutions, babblers began to reason ...

at the end - the code in Python - the shortest and most readable)

Those who replied in essence - thanks for an interesting discussion)

---------- Posted 14.06.2020 at 13:24 ----------

timo-71:
Come on, probably joking.

Important, but I did not say that the complex or for seniors - so fun. I like to have spent more time writing tests than on the task itself)

Всего: 7322