﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31692	compilemessages needlessly runs msgfmt on unchanged .po files	Per Cederqvist	Claude Paroz	"I have a project where running `django-admin compilemessages` takes 1.75 seconds. Running it again, when all the `.mo` files already exists and are up-to-date, also takes 1.75 seconds.

I propose that `compilemessages.py` is changed so that it only invokes `msgfmt` when it would do anything useful. This can be implemented by checking the mtime of the `.po` file and the corresponding `.mo` file. (If statting the `.mo` file fails, treat that as if the mtime was 0.) Only submit the command to the `executor` if the mtime of the `.po` file is greater than that of the `.mo` file.  In effect: don't do anything if the `.mo` file is newer than the `.po` file.

There is one issue with this: the way the code currently uses the `is_writable` function. Since it modifies the mtime of the `.mo` file, you would have to perform the stat of the `.mo` file before you check if it is writable. (Or, you could just remove the `is_writable` function and its use. That feature is, in my opinion, of dubious value, and it doesn't appear to be documented.)

After I made the changes above, the runtime in the common case where nothing needs to be done was reduced from 1.75 seconds to 0.2 seconds.

(Unfortunately, I doubt that I will be able to get a Corporate Contributor License Agreement signed, so I can unfortunately not contribute my change.)

1.75 seconds may not be much, but when a CI system does it repeatedly, it adds up."	Cleanup/optimization	closed	Core (Management commands)	dev	Normal	fixed			Accepted	1	0	0	0	0	0
