Comment 12 for bug 487251

Revision history for this message
xrg (xrg) wrote : Re: [Bug 487251] Re: _ translate function blows up if used in method with a parameter named 'args': AttributeError: 'list' object has no attribute 'get' in lang = args[-1].get('lang', False)

On Thursday 30 September 2010, you wrote:
> Hello Panos,
>
> We can also have a solution for this omitting the args, as taking
> args[-1] is not feasible it can crash the system or it can also give
> false result too for e.g. if the last argument is a dictionary but not
> context . So I have a better solution for translate._() method. Please
> check the attached patch and give your views.
>
> Thanks.
>
> ** Patch added: "translate_patch.diff"
>
> https://bugs.launchpad.net/openobject-server/+bug/487251/+attachment/16564
> 80/+files/translate_patch.diff

Please remember that the _() must be a fast function, may be called much more
often than we really want it (because of bad code, in fact). So it is
important to keep the code as simple (and "cheap") as possible. Every stack
frame we open, every loop or variable instantiation will add some "weight" to
the function, which we should ideally avoid.