1 |
Might help if I had attached the patch.. |
2 |
|
3 |
Alec Joseph Warner wrote: |
4 |
> Author : TGL |
5 |
> Purpose : |
6 |
> While profiling a script that reads CONTENTS files using |
7 |
> 'dblink.getcontents()', i've seen that it was spending quite some time |
8 |
> in ~400k calls to 'os.path.normpath()' (one per referenced element). I |
9 |
> think there is nothing to normalize here (paths in CONTENTS files are |
10 |
> already normal by construction) and thus this calls could be avoided. |
11 |
> |
12 |
> The one-line patch i will attach does this. It's effect is easy to |
13 |
> check, for instance with equery: |
14 |
> |
15 |
> Before: |
16 |
> % time equery belongs /bin/bash > /dev/null |
17 |
> real 0m13.583s |
18 |
> user 0m13.215s |
19 |
> sys 0m0.249s |
20 |
> |
21 |
> After: |
22 |
> % time equery belongs /bin/bash > /dev/null |
23 |
> real 0m6.526s |
24 |
> user 0m6.218s |
25 |
> sys 0m0.246s |
26 |
> |
27 |
> A quick testing of normpath in python shows it acts how I think it does, |
28 |
> which means i think this is patch is good to put in, it's short simple, |
29 |
> and shouldn't break anything. |
30 |
> |
31 |
> I kind of see Brian's point in being defensive in filenames though |
32 |
> (os.path.normpath("///////var/db/pkg/fex") being invalid in a CONTENTS |
33 |
> file but still usable by most(?) calls in python, which will just figure |
34 |
> it all out anyway. |
35 |
> |
36 |
> If portage errored on invalid paths in CONTENTS file, I would see |
37 |
> leaving it there, but if it doesn't help anything ( because it doesn't |
38 |
> hurt anything either, right? :) ) then why do the work? |
39 |
> |
40 |
> *has ranted too long :P* |
41 |
> |
42 |
> -Alec Warner (antarus) |
43 |
> |