Re: [RFC] Internal operator overloading and GMP improvements
| From: | Nikita Popov | Date: | Sun, 12 May 2013 19:49:32 +0000 |
| Subject: | Re: [RFC] Internal operator overloading and GMP improvements | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67406@lists.php.net to get a copy of this message | ||
On Sun, May 12, 2013 at 9:02 PM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> I think this is a misunderstanding. I do not suggest to use GMP for all
> arithmetic and also do not suggest to auto-promote to GMP for large numbers.
>
> The operator overloading only comes into play if one of the operands is
> already a GMP instance.
>
> Regarding performance: The addition of the operator overloading does have
> a measurable impact on performance.
>
Ooops, that was a typo. I wanted to say "does NOT have a measurable impact
on performance".
> The switch of GMP from resources to objects also does not show any clear
> change either way. What does become faster is if a gmp function gets a
> non-gmp argument and needs to cast it to GMP (this is faster because now
> only the mpz_t instance is created and not a full resource). Obviously when
> the overloaded operators are used rather than the functions it's faster too.
>
I tweaked the implementation a bit and now it seems to be faster in any
case. I added some numbers in
https://wiki.php.net/rfc/operator_overloading_gmp#performance
Nikita