Using fixed variables probably doesn't help
Robert Collins
robertc at robertcollins.net
Fri Jun 16 15:46:32 BST 2006
On Fri, 2006-06-16 at 09:36 -0500, John Arbash Meinel wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Robert Collins wrote:
> > On Fri, 2006-06-16 at 09:26 -0500, John Arbash Meinel wrote:
> >
> >
> >> Sure, but that means it won't be the same string that everyone else
> >> uses. So you lose the fast lookups. My point was to have the returned
> >> strings be interned, so when 'walkdirs()' says 'if kind == 'unknown'
> >> then stat' it doesn't have to be a string comparison.
> >>
> >> In my testing it was only about 10% faster, but it was faster.
> >
> > Is it reasonabel to do this by having osutils get the strings from the
> > readdir module?
> >
> > If not, we can experiment with teaching the pyrex code to use interned
> > strings.
> >
> > Rob
>
> Well, you could replace the global variables if it can load the C extension.
> But you lose the value of having all the other occurrences of 'unknown'
> be interned.
I mean, in 'bzrlib.osutils':
from bzrlib.readdir import *
In the python module and the pyrex module there is a definition of the
kinds. You can then call 'intern(kind)' on each.
> You could pass the variables into the pyrex module, or you could just
> call "<char*> unknown = intern('unknown')".
>
> I would guess that would work.
Well, if doing this I'd just do:
from bzrlib.osutils import kind_directory, kind_file, ...
-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060617/e0c98c34/attachment.pgp
More information about the bazaar
mailing list