[MERGE][bug #297831] don't call chdir('')

Aaron Bentley aaron at aaronbentley.com
Wed Nov 19 21:26:49 GMT 2008


John Arbash Meinel wrote:
> Aaron Bentley wrote:
>> John Arbash Meinel wrote:
>>> So I actually disagree with this, as "if path" can be translated into a
>>> very cheap "PyObject_True(path)" call, rather than having to create a
>>> temporary string object for "", and then call PyObject_Compare(path,
>>> tmp_obj).
>> If you can demonstrate that this has a significant impact on
>> performance, I'll let it in as-is.

> Would the .02usec per loop have a measurable impact on the overall time
> of "bzr status". I would guess it is lost mostly in the noise. Still
> 
> 1) it *is* faster

I said "significantly" faster.  As an optimization, this is premature.

> 2) I find the code just as easy to read, others may disagree.

Yeah, they do.  So I'll retract my "tweak" and someone else can review it.

> 3) You're version of the check doesn't really protect anything, as it
> just means we end up calling PyStringAsString on an empty list/None/etc.
> (though it would have long since failed in the calling code, but
> assuming it got that far...)

Yes, actually, it does.  My version would pass None to chdir, which
would make it raise a TypeError.

Your version would skip the chdir, so it would silently pass and return
bogus results.

Aaron



More information about the bazaar mailing list