Compiled and faster black formatter? (Cython?)

I integrated Black with my code editor but it takes some time to format every time I save a .py file.

Is there a way to compile it with Cython to speed things up?

You’d first have to do some profiling to see where the slow parts are. It could be file reading that’s slow, or code parsing, syntax tree construction, or reg-ex matching, all of which are already implemented in C

2 Likes

I integrated Black with my code editor but it takes some time to format every time I save a .py file.

Another solution could be to use something like pre-commit to only format files that changes. It runs on commit though not on save.