Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99711 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47357 invoked from network); 3 Jul 2017 15:50:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2017 15:50:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.223.182 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.223.182 mail-io0-f182.google.com Received: from [209.85.223.182] ([209.85.223.182:35942] helo=mail-io0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/D3-15131-ED76A595 for ; Mon, 03 Jul 2017 11:50:54 -0400 Received: by mail-io0-f182.google.com with SMTP id z62so58738145ioi.3 for ; Mon, 03 Jul 2017 08:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cBCrWrUNla5fx2rU31TSysweQ7Aym/7x9UxK6PkM68c=; b=CC3Iy/Fi8Qpliy8VprujJrRCiT4QgII0VZJvqdLDaGy4rsnpgIco9F6b7cSl+r5iGU vgURe7oZPoQWuZTOcUl8bTu5c/EoDiTbSi6WMYbHbc6BtH1ZtOAmadiNBzeap/Y6qa3a Rl3GR+z4rPvqRVj7tgAcDOaYiaSxGz22ZyeyxXqd+Fnlh5SqiDW2ykLR1zPili4QZfqL f3rl0iZb+y3t2V0xmO8VsSEcdme4DIKSH5ZoRfDgehJTAhuHWuyGk8sErVIFdJXYkIiO tGgCNyDmeV7QIGdtZlHCzOkIcfAHBUGl6NG+e2AjSdU2GtWYqRVJpzmZ+Yfuvh9qdeVA +A2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cBCrWrUNla5fx2rU31TSysweQ7Aym/7x9UxK6PkM68c=; b=IMqGo2KT2fE2fF8h4OZ8eEgr/H0y2IvCy9v+d56xOYzDWEuGi4cyU0izbGlBulPsNf Nkolt22sJPsMyWzW2dJLnXYwyLhK50H4cUmmxacPnI9eLWLwQ7qoTKa5FTXrSOJe4a18 RNXf9efk6Z6I/x86jlhbS8DnrvUKIMbSZf6GolJwSYepL4SnhobM7IubCBMzU1x5NVCm mPFR+K8o0F/j77+ImVi0XsEEcI0vA5keifo7P0QIFjJMEYOQ1Aub7XbTZIG1NPVXIPrE 2oA7jKV/MUv7iZva+89eupnaSqIKEyiNos7TROZDzGrYENIhfmxm9m/Jd2JFteL0Gc0v 31Zw== X-Gm-Message-State: AKS2vOzP0/H9rz/DYKTQFx3w8bYhR138v37gDd9liHHkO0o67hH8KTZ2 2+EOHohLM6iOBIPvhkQ= X-Received: by 10.107.181.22 with SMTP id e22mr39678585iof.85.1499097051621; Mon, 03 Jul 2017 08:50:51 -0700 (PDT) Received: from mail-io0-f182.google.com (mail-io0-f182.google.com. [209.85.223.182]) by smtp.googlemail.com with ESMTPSA id 84sm1897454iog.39.2017.07.03.08.50.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jul 2017 08:50:51 -0700 (PDT) Received: by mail-io0-f182.google.com with SMTP id z62so58737913ioi.3 for ; Mon, 03 Jul 2017 08:50:51 -0700 (PDT) X-Received: by 10.107.15.80 with SMTP id x77mr18513772ioi.2.1499097050898; Mon, 03 Jul 2017 08:50:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.246.71 with HTTP; Mon, 3 Jul 2017 08:50:30 -0700 (PDT) In-Reply-To: References: Date: Mon, 3 Jul 2017 17:50:30 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Niklas Keller Cc: Sara Golemon , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] "Reader" as alternative to Iterator From: andreas@dqxtech.net (Andreas Hennings) On Mon, Jul 3, 2017 at 9:09 AM, Niklas Keller wrote: > > Hey Andreas, > > what you're trying to do here seems to be premature optimization. While you > save a bunch of method calls, your I/O will be the actual bottleneck there. > It's entirely fine to implement such logic in userland. I will let this stand unchallenged, until I have some reproducible data.. > > Amp has a similar interface for its streams, but those have only string|null > as types. If you want to allow all values, you either need a second method > or need to wrap all values in an object. > > http://amphp.org/byte-stream/#inputstream + > http://amphp.org/amp/iterators/#iterator-consumption This library looks interesting. It seems to do a lot more than I currently need, with its concurrency approach. I am a bit puzzled by the yield keyword in this code: while (($chunk = yield $inputStream->read()) !== null) { $buffer .= $chunk; } In my experience with generators so far, you either use yield for sending or for receiving. So either "yield $value;" or "$value = yield;" In this case it seems to do both. I assume this is to achieve the concurrency. (This is not an argument for or against anything, just an observation)