Commits

Anonymous committed 98f224d

Made removeorphanpycs an order of magnitude faster

Comments (0)

Files changed (2)

 
 # Remove .pyc files without a corresponding .py
 function removeorphanpycs() {
-    [ -z "$PROJECT_ROOT" ] && echo "No \$PROJECT_ROOT" 1>&2 && return 1
-    local pyc
-    for pyc in `find -H $PROJECT_ROOT -name \*.pyc`; do
-        [ -f  `echo $pyc | sed 's/c$//'` ] || rm -v $pyc
-    done
+    [ -z "$PROJECT_ROOT" ] && echo "No \$PROJECT_ROOT" 1>&2 && return 1;
+    diff --old-line-format= --new-line-format=%l --unchanged-group-format= \
+        <(find -H $PROJECT_ROOT -name \*.py) \
+        <(find -H $PROJECT_ROOT -name \*.pyc | sed 's/c$//') | \
+        sed 's/$/c/' | xargs rm -v
 }
 
 # Change directory to Django project

mysite/settings/._generic.py

Binary file removed.