Инструмент для определения, что самая низкая версия требуемого Python?

из-за того, что когда вы выполняете import math, вы импортируете все классы функций или что-либо еще в математической библиотеке, чем используете больше оперативной памяти и т. Д., Но при выполнении from math import sqrt вы импортируете только функцию sqrt во все математические библиотеки

48
задан dbr 29 April 2009 в 22:21
поделиться

2 ответа

Вдохновленный этим замечательным вопросом, я недавно написал сценарий, который пытается это сделать. Вы можете найти его на github в pyqver .

Он достаточно завершен, но есть некоторые аспекты, которые еще не обработаны (как упомянуто в файле README). Не стесняйтесь раскошелиться и улучшить его!

41
ответ дан 26 November 2019 в 19:03
поделиться

Not an actual useful answer but here it goes anyway. I think this should be doable to make (though probably quite an exercise), for example you could make sure you have all the official grammars for the versions you want to check, like this one .

Then parse the bit of code starting with the first grammar version. Next you need a similar map of all the built-in module namespaces and parse the code again starting with the earliest version, though it might be tricky to differentiate between built-in modules and modules that are external or something in between like ElementTree.

The result should be an overview of versions that support the syntax of the code and an overview of the modules and which version (if at all) is needed to use it. With that result you could calculate the best lowest and highest version.

8
ответ дан 26 November 2019 в 19:03
поделиться
Другие вопросы по тегам:

Похожие вопросы: