start = time.time() with open('task-1.json') as data: f = json.load(data) print(len(f)) with open('task-1.json') as data: content = data.read() row = json.loads(content) with open('res-task-1.json', 'w') as f: f.write('[')
for item in row: if item.get('scores') >= 0.7: f.write(json.dumps(item)) f.write(',') f.write(']') print(time.time()-start)
две строки тут лишние - толкь для подсчета времени
start = time.time () with open ( 'task-1.json') as data: f = json.load (data) print (len (f)) with open ( 'task-1.json') as data: content = data.read () row = json.loads (content) with open ( 'res-task-1.json', 'w') as f: f.write ( '[')
for item in row: if item.get ( 'scores')> = 0.7: f.write (json.dumps (item)) f.write ( ',') f.write ( ']') print (time.time () - start)
two lines then the extra - Only for counting time
an average of 0.03 seconds is performed on the core i5 quad
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 в реальности, там уже несильно важно.
Дв а принципе, я ничего не имею против кода на пхп, это не тема для срача)
Спасибо всем за участие, будете у нас в Минске - с удовольствием пересекусь за пивом. Думаю тема исчерпана
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
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)
две строки тут лишние - толкь для подсчета времени
в среднем выполняется за 0.03 сек на core i5 quad
было 10000 строк стало 2995
two lines then the extra - Only for counting time
an average of 0.03 seconds is performed on the core i5 quad
It was 10,000 lines in 2995 was
Че-то быстро ты, а я хотел задачки по сложнее закинуть, не хочешь?
Создавай тему, почему бы и нет
Che's something you quickly, and I would like puzzles on the harder to throw, do you want?
Create a theme, why not?
Ну и опять таки, ты не скинул весь файл с кодом
собственно, сам код - строки 9-10, остальное - чтобы проверить в любой питоновской консоли. В рамках задачи мне потребовалось вставить 2 строки в существующий код - проверка на ключ, что нужно фильтровать и сама фильтрация.
Про скорость - понятно что го будет быстрее, но все это компилируется в сpython в реальности, там уже несильно важно.
Дв а принципе, я ничего не имею против кода на пхп, это не тема для срача)
Спасибо всем за участие, будете у нас в Минске - с удовольствием пересекусь за пивом. Думаю тема исчерпана
Well, again, you're not thrown off the whole code file
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
но короткий же != самый быстрый?
Проверь, если есть сомнения)
but also short! = is the fastest?
Check, if in doubt)
Это вы наивный Я несколько месяцев своей жизни на это потратил, и ещё может потрачу. Конечно будут пользоваться Посмотрел бы я на вас когда сделаете что-то уникальное, что превосходит существующие продукты.
Буду только рад за тебя, если получится. Просто пока что все, кроме тебя видят, что ты занимаешься ерундой. Твои решения ничего не дают ни в плане простоты, скорости, универсальности. да ты и сам не понимаешь, к чему стремишься)
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)