[RFC] using `if WINDOWS` instead of `if sys.platform == 'win32'`?
Alexander Belchenko
bialix at ukr.net
Thu Sep 6 11:38:03 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Vincent Ladeuil пишет:
>>>>>> "bialix" == Alexander Belchenko <bialix at ukr.net> writes:
>
> bialix> There are around 100 places where bzrlib code try to check
> bialix> if it run on Windows by comparing `sys.platform == 'win32'`
> bialix> or similar. About the half of this checks is inside core code,
> bialix> and another half in tests.
>
> bialix> I'd like to change this places by defining in bzrlib/__init__.py
> bialix> constant with name 'WINDOWS' or something similar and use
> bialix> this constant where needed.
>
> bialix> WINDOWS = sys.platform == 'win32'
>
> bialix> ...
>
>
> bialix> if WINDOWS:
> bialix> do_something_crazy()
>
> bialix> if not WINDOWS:
> bialix> do_another_thing()
>
>
> bialix> Proposed change should make code more clear.
> bialix> Anyone have objections or suggestions?
>
> Can you try to reduce the 100 places to functions inside osutils
> instead ?
Why for?
Calling a function in Python is expensive operation.
Check boolean variable should be much faster.
[µ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG39iLzYr338mxwCURAktkAKCNHySDlNwbMb6EkWHhbkDvjDEpDwCeNCvU
Lz21ETrtI2sGEfBs5fG/sOM=
=v2D6
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list