ufl team mailing list archive
-
ufl team
-
Mailing list archive
-
Message #00679
Re: Alternative faster assertion method
On Wed, Feb 4, 2009 at 2:12 PM, Johan Hake <hake@xxxxxxxxx> wrote:
> On Wednesday 04 February 2009 10:42:12 Martin Sandve Alnæs wrote:
>> I won't change the code everywhere to do this now,
>> but if profiling in the future shows all the ufl_assert
>> calls to take significant time, we can do this:
>>
>> isinstance(a, Expr) or error("Expecting Expr instance.")
>>
>> instead of this:
>>
>> ufl_assert(isinstance(a, Expr), "Expecting Expr instance.")
>>
>> They do exactly the same, the length is about the same,
>> but the former is much cheaper as long as it doesn't trigger.
>
> Some annoying questions ;)
>
> How much is much and how does this compare to all other things you are doing?
>
> Johan
1) I haven't measured, but function calls are expensive and with the
ufl_assert approach the function is entered every time.
2) Don't know, which is why I wrote "if profiling ..."
Martin
Follow ups
References