natasha / yargy

Rule-based facts extraction for Russian language
MIT License
315 stars 40 forks source link

Реализация BFS в yargy.rule.constructors использует список как очередь #80

Open ivodopyanov opened 3 years ago

ivodopyanov commented 3 years ago

Метод bfs_rule в yargy.rule.constructors использует list как queue. Документация python по этому поводу сообщает

It is also possible to use a list as a queue, where the first element added is the first element retrieved (“first-in, first-out”); however, lists are not efficient for this purpose. While appends and pops from the end of list are fast, doing inserts or pops from the beginning of a list is slow (because all of the other elements have to be shifted by one).

To implement a queue, use collections.deque which was designed to have fast appends and pops from both ends.

https://docs.python.org/3/tutorial/datastructures.html#using-lists-as-queues

Это начинает сказываться, например, при использовании больших газеттиров и morph_pipeline.