Підвищення продуктивності коду мовою РYТНОN з використанням техніки переписувальних правил

Запропоновано підхід підвищення продуктивності коду, написаного мовою Python, шляхом перетворення фрагментів коду до більш ефективних мов Cython та C++. Використано високорівневі алгебраїчні моделі та техніку переписувальних правил для автоматизації перетворень програмного коду. Проведено порівняння...

Ausführliche Beschreibung

Gespeichert in:
Bibliographische Detailangaben
Veröffentlicht in:Проблеми програмування
Datum:2020
1. Verfasser: Жереб, К.А.
Format: Artikel
Sprache:Ukrainian
Veröffentlicht: Інститут програмних систем НАН України 2020
Schlagworte:
Online Zugang:https://nasplib.isofts.kiev.ua/handle/123456789/180457
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
Назва журналу:Digital Library of Periodicals of National Academy of Sciences of Ukraine
Zitieren:Підвищення продуктивності коду мовою РYТНОN з використанням техніки переписувальних правил / К.А. Жереб // Проблеми програмування. — 2020. — № 2-3. — С. 115-125. — Бібліогр.: 13 назв. — укр.

Institution

Digital Library of Periodicals of National Academy of Sciences of Ukraine
Beschreibung
Zusammenfassung:Запропоновано підхід підвищення продуктивності коду, написаного мовою Python, шляхом перетворення фрагментів коду до більш ефективних мов Cython та C++. Використано високорівневі алгебраїчні моделі та техніку переписувальних правил для автоматизації перетворень програмного коду. Проведено порівняння часу виконання простих програм – початкової версії мовою Python, різних версій перетвореного коду, а також автоматичних засобів Cython та PyPy, що демонструє ефективність запропонованого підходу. Предложен подход повышения производительности кода, написанного на языке Python, с помощью преобразования фрагментов кода в более эффективные языки Cython и C ++. Использованы высокоуровневые алгебраические модели и техника переписывающих правил для автоматизации преобразований кода. Проведено сравнение времени выполнения простых программ – начальной версии на языке Python, различных версий преобразованного кода, а также автоматических средств Cython и PyPy, что демонстрирует эффективность предложенного подхода. Python is a popular programming language used in many areas, but its performance is significantly lower than many compiled languages. We propose an approach to increasing performance of Python code by transforming fragments of code to more efficient languages such as Cython and C++. We use high-level algebraic models and rewriting rules technique for semi-automated code transformation. Performance-critical fragments of code are transformed into a low-level syntax model using Python parser. Then this low-level model is further transformed into a high-level algebraic model that is language-independent and easier to work with. The transformation is automated using rewriting rules implemented in Termware system. We also improve the constructed high-level model by deducing additional information such as data types and constraints. From this enhanced high-level model of code we generate equivalent fragments of code using code generators for Cython and C++ languages. Cython code is seamlessly integrated with Python code, and for C++ code we generate a small utility file in Cython that also integrates this code with Python. This way, the bulk of program code can stay in Python and benefit from its facilities, but performance-critical fragments of code are transformed into more efficient equivalents, improving the performance of resulting program. Comparison of execution times between initial version of Python code, different versions of transformed code and using automatic tools such as Cython compiler and PyPy demonstrates the benefits of our approach – we have achieved performance gains of over 50x compared to the initial version written in Python, and over 2x compared to the best automatic tool we have tested.
ISSN:1727-4907