Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67407 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4989 invoked from network); 12 May 2013 19:57:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2013 19:57:12 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.43 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.43 mail-pa0-f43.google.com Received: from [209.85.220.43] ([209.85.220.43:39602] helo=mail-pa0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/95-55400-614FF815 for ; Sun, 12 May 2013 15:57:11 -0400 Received: by mail-pa0-f43.google.com with SMTP id hz10so4114444pad.30 for ; Sun, 12 May 2013 12:57:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:x-originating-ip:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:x-gm-message-state; bh=t5rqlhr00lUgFedb5ltOjRHTU6UUQ3XuwRb86CMRVx8=; b=EM8ULYQwxoXH6uGzM+AFCsmwHArYFTPdVLiS2P3mRGaXzCUdPA6G6nwYdcu5nLFeJD Gifj5Yu9oYIWJAhl/+SFgpxxHI+b/oZfBkFv3ymfS+7HUc5ZN+76q8T0Y5Q9/LgBgMbI 83SDRvjeFHA0ZUWbTZYgv493dmWQWQ6Y/+aUJ4mqlyFkgUMr5AoGuAh/POQSAu4eqXWj BTmrtJymrJfjJ27E17/9y7VhW7Ru4D5fPdKn0toQRLUbMk8Xgs6XIXIEVF1zsxAejFlT AK/cIzkoSOwt6n+1XPBa40SDzd8TGa4APP5f4O5Bn/w98bH83Jw3uWWcGW+4rPzFa2U3 VPLA== MIME-Version: 1.0 X-Received: by 10.68.27.9 with SMTP id p9mr25826881pbg.139.1368388628029; Sun, 12 May 2013 12:57:08 -0700 (PDT) Sender: php@golemon.com Received: by 10.70.51.229 with HTTP; Sun, 12 May 2013 12:57:07 -0700 (PDT) X-Originating-IP: [98.210.180.187] In-Reply-To: References: <518FD653.6070705@daylessday.org> Date: Sun, 12 May 2013 12:57:07 -0700 X-Google-Sender-Auth: sQ4APBKEXfW1TmjU36KtykNMrMY Message-ID: To: Nikita Popov Cc: Antony Dovgal , PHP internals Content-Type: multipart/alternative; boundary=bcaec52162f316b07a04dc8ace20 X-Gm-Message-State: ALoCoQlK25QaR+GkKgaidy+f6CS8lzIihMRZIsEHNX2Ke7y1JZ5Zn++mwKJwRcrrM7C9ARAbT2mh Subject: Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements From: pollita@php.net (Sara Golemon) --bcaec52162f316b07a04dc8ace20 Content-Type: text/plain; charset=ISO-8859-1 Are we ignoring the ZEND_IS_SMALLER issue? if ($gmp > 123) { ... } There's no ZEND_IS_GREATER opcode, so it gets quietly turned into: if (123 < $gmp) { ... } Which will be confusing. I dealt with this in operator by having the user apply a patch before building: https://github.com/php/pecl-php-operator/blob/master/compare-greater-5.1.2.diff If we're going to bake this into ZE, then we should just add ZEND_IS_GREATER(_OR_EQUAL) opcode. -Sara On Sun, May 12, 2013 at 12:02 PM, Nikita Popov wrote: > On Sun, May 12, 2013 at 7:50 PM, Antony Dovgal > wrote: > > > On 2013-05-12 19:25, Nikita Popov wrote: > > > >> Hi internals! > >> > >> https://wiki.php.net/rfc/**operator_overloading_gmp< > https://wiki.php.net/rfc/operator_overloading_gmp> > >> > >> This RFC proposes to add operator overloading for INTERNAL classes. > >> Furthermore it exemplarily implements the new API for GMP. > >> > > > > IMO the proposal B is quite reasonable change, but the proposal A (i.e. > > the operator overloading part) is definitely an overkill. > > A simple benchmark should demonstrate that using GMP for basic arithmetic > > would kill performance in quite a brutal way. > > > > 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. 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. > > Nikita > --bcaec52162f316b07a04dc8ace20--