Origins¶
django-codemod was an existing Django auto-upgrade tool, written by Bruno Alla. Unfortunately its underlying library LibCST is (or at least was) particularly slow, making it annoying to run django-codemod on every commit and in CI.
django-upgrade started as an experiment in reimplementing such a tool using the same techniques as the fantastic pyupgrade. The tool leans on the standard library’s ast and tokenize modules, the latter via the tokenize-rt wrapper. This means it will always be fast and support the latest versions of Python.
In a quick benchmark against a medium Django repository, with 153k lines of Python:
django-codemod took 133 seconds
django-upgrade took 0.5 seconds
Since its creation, django-upgrade has seen great adoption.