Skip to content

Сhange 1#18

Open
AleksandraG88 wants to merge 54 commits into
mainfrom
AlexGrishchenko
Open

Сhange 1#18
AleksandraG88 wants to merge 54 commits into
mainfrom
AlexGrishchenko

Conversation

@AleksandraG88
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё ОК. Только одно небольшое замечание!

Comment thread Practice/GrishchenkoA/2.1.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошо, но есть несколько замечаний (в основном, по стилю).

Comment thread Practice/GrishchenkoA/2.1.py
Comment thread Practice/GrishchenkoA/3.1.py Outdated
Comment thread Practice/GrishchenkoA/3.1.py Outdated
Comment thread Practice/GrishchenkoA/3.4.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё хорошо, но есть замечания.

Comment thread Practice/GrishchenkoA/3.1.py Outdated
Comment thread Practice/GrishchenkoA/3.5.py Outdated
Comment thread Practice/GrishchenkoA/3.5.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо 3.5.py все-таки домучить.

Comment thread Practice/GrishchenkoA/3.5.py Outdated
Comment thread Practice/GrishchenkoA/3.5.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всё супер! Но есть несколько замечаний!

Comment thread Practice/GrishchenkoA/3.1.py Outdated
Comment thread Practice/GrishchenkoA/4.1.py Outdated
Comment thread Practice/GrishchenkoA/4.3.py Outdated
Comment thread Practice/GrishchenkoA/4.5.py Outdated
Comment thread Practice/GrishchenkoA/4.5.py Outdated
Comment thread Practice/GrishchenkoA/4.8.py Outdated
Comment thread Practice/GrishchenkoA/4.2.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почти) Осталось одно существенное и одно маленькое замечание.

Comment thread Practice/GrishchenkoA/4.5.py Outdated
Comment thread Practice/GrishchenkoA/4.5.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошо. Но есть замечания.

Comment thread Practice/GrishchenkoA/5.3.py Outdated
Comment thread Practice/GrishchenkoA/5.3.py Outdated
Comment thread Practice/GrishchenkoA/5.4.py Outdated
Comment thread Practice/GrishchenkoA/5.4.py
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Стало лучше, но замечания остались.

def find_min_index(lst):
for i,d in enumerate(lst):
d = min(lst[i:])
d, lst[i] = lst[i], d
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мы так элементы теряем. Не стоит здесь надеяться на стандартную функцию min.
Лучше в этой функции find_min_index просто найти индекс минимального элемента:

min_idx = 0
min_val = lst[min_idx]
for i, d in enumerate(lst):
    if d < min_val:
        min_val = d
        min_idx = i
return min_idx

А перестановку можно и за пределами функции сделать.

if number == int(v):
for k in range(len(lst)):
del lst[k][y]
for y, v in enumerate(d):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это получается, что мы дважды пробегаемся по одной и той же строке, сначала обращаясь к ней через lst, потом через lst_1 (опять же, глобальную переменную). Это неэффективно!
Помните задачу с занятия про удаление чётных элементов из списка? Здесь стоит применить тот же подход с циклом while и без лишних циклов в стр. 7-10.

Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил еще несколько замечаний.

Comment thread Practice/GrishchenkoA/6.1.py Outdated
Comment thread Practice/GrishchenkoA/6.1.py
Comment thread Practice/GrishchenkoA/6.2.py Outdated
Comment thread Practice/GrishchenkoA/6.2.py Outdated
Comment thread Practice/GrishchenkoA/6.2.py Outdated
Comment thread Practice/GrishchenkoA/6.2.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Одно замечание оставил. Ну и по старым задачам замечания тоже нужно исправить.

Comment thread Practice/GrishchenkoA/6.2.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил пару вопросов.

Comment thread Practice/GrishchenkoA/6.2.py Outdated

class WrapStrToFile:
def __init__(self):
self.filepath = tempfile.mktemp()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Должен ли путь к файлу быть доступен вне класса? Если нет, то как это можно показать?

Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил ещё несколько замечаний.

Comment thread Practice/GrishchenkoA/7.2.py
Comment thread Practice/GrishchenkoA/7.3.py
Comment thread Practice/GrishchenkoA/7.3.py Outdated
Comment thread Practice/GrishchenkoA/8.1.py
Comment thread Practice/GrishchenkoA/8.1.py Outdated
Comment thread Practice/GrishchenkoA/8.3.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавил новые замечания. Старые тоже нужно исправить!

Comment thread Practice/GrishchenkoA/9.2.py Outdated
#-*- coding: utf-8 -*-
import re

st = re.compile(r"git [a-z]{3,4} \Z|git [a-z]{4,8} \W+[a-z]{1,3}\W+[a-z]{2,8}.[a-z]{6}|git [a-z]{4,8}.{55}|git [a-z]{3,4} [a-z]{6}.?[a-z]{2,4}|git [a-z]{3,4}")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ОК. Только PEP8 забывать не надо: строка длинновата получается.

Comment thread Practice/GrishchenkoA/7.2.py
Comment thread Practice/GrishchenkoA/8.1.py Outdated
Copy link
Copy Markdown
Owner

@IlyaOrlov IlyaOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Замечания еще остались.

def __next__(self):
text = ""
while self.ind != -1:
file.seek(self.ind)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтобы не заморачиваться с seek и tell используйте self.file_new! Он сам будет сдвигаться с позиции на позицию при каждом self.file_new.read(1) и помнить свою предыдущую позицию. Даже self.ind не понадобится.

lst = []
for i in range(start, end + 1):
if i > 1:
for y in range(2, i):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Достаточно проверять делители до корня квадратного из i.

lst_time2.append(time.perf_counter() - start)
print(f"Общее время расчета через многопроцессорность занял в секундах: {lst_time2}")

# Быстрее всего данная задача решается через многопоточность No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Стоит получше присмотреться к результатам! У многопоточности здесь вообще не оснований выбиться в лидеры.
Интересно, кстати, зачем хранить единственное значение - время работы алгоритма - в списке?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants