__pycache__, one more good reason to stck with Python 2?

Sherm Pendley sherm.pendley at gmail.com
Tue Jan 18 09:45:33 EST 2011


Peter Otten <__peter__ at web.de> writes:

> Carl Banks wrote:
>
>> Well the former deletes all the pyc files in the directory tree
>> whereas the latter only deletes the top level __pycache__, not the
>> __pycache__ for subpackages.  To delete all the __pycache__s you'd
>> have to do something like this:
>> 
>> file . -name __pycache__ -prune -exec rm -rf {} \;
>> 
>> or, better,
>> 
>> file . -name __pycache__ -prune | xargs rm -rf
>> 
>> Still not anything really difficult.  (I don't think a lot of people
>> know about -prune; it tells find don't recursively descend.)
>
> What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'?

Exec launches a new instance of 'rm' for each found file, while xargs
launches a single instance, and passes the list of found files as arg-
uments.

Probably not a big deal in this case, but if you're passing a long list
of files to a script that has a long startup time, it can make a big
difference.

sherm--

-- 
Sherm Pendley
                                   <http://camelbones.sourceforge.net>
Cocoa Developer



More information about the Python-list mailing list