Gentoo Archives: gentoo-portage-dev

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

Replies

Subject Author
[gentoo-portage-dev] Re: os.path.normpath patch ( bug 90444 ) Alec Joseph Warner <warnera6@×××××××.edu>
Re: [gentoo-portage-dev] os.path.normpath patch ( bug 90444 ) Brian Harring <ferringb@g.o>