[MERGE] bzrlib.osutils fixes

Aaron Bentley aaron.bentley at utoronto.ca
Fri Mar 9 13:45:07 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dmitry Vasiliev wrote:
> John Arbash Meinel wrote:
>> Some small things....
>>
>> _directory_kind was really a misfeature. We were trying to re-use the
>> same string object, but it turns out that python automatically interns
>> any strings that look like identifiers (\w+). I think the code would
>> be a lot clearer if we just used 'directory' everywhere like we use
>> 'file'.
>>
>> I understand why tuple versus list doesn't matter, (because we just
>> re-generate it as a different tuple later) but it may be better to
>> have an explicit comment about it.
> 
> Done in the attached version.

Also, Robert has some notes that tuples are 5x faster than lists.

http://bazaar-vcs.org/RobertCollins

So depending on how frequently this code is used, it might be more
efficient to do:

                 new_dirblock = []
                 for info in dirblock:

                     self.assertIsInstance(info[4], unicode)
                     new_4 = info[4].encode('utf8')
                     new_dirblock.append(info[:4] + (new_4,) +
                                         info[5:])
                 dirblock = new_dirblock

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF8WTj0F+nu1YWqI0RAjDUAJ4xchPcXoIwIjNOiHkwhaCv7BbecgCfafma
eh7DfmlbbfUOMvUCOBNvsb0=
=P2F9
-----END PGP SIGNATURE-----



More information about the bazaar mailing list