Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104818 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 3882 invoked from network); 20 Mar 2019 13:48:47 -0000 Received: from unknown (HELO mail-oi1-f196.google.com) (209.85.167.196) by pb1.pair.com with SMTP; 20 Mar 2019 13:48:47 -0000 Received: by mail-oi1-f196.google.com with SMTP id e22so1404807oiy.0 for ; Wed, 20 Mar 2019 03:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2h0dLLCUZOiNdnFtLTsymdkgX1iFI50dFM6FVDv6Whg=; b=D5u2DD7+dXP4fcG20bdvHTuw6KYa8LbgJOcI3miHFOb9s8RBO/EzlFObp13xYOCT/+ cvY9zUPFx51znq1VLlRIaiIJuqSVqwNFD1LDHucSN6cl91tN/+m1cN6U2VlZaqUMmCmk OQEUlqKnvT+RebyjyZtCKvfA0V4fAN/LrXAPrNGIiK1we+HngjnZK+zmb9/kpcHob1xk ItmECcJXFDHjmtQ6jA2YJpNHTOEOj0f6EL+7MO6B/dJ1XAEMRfkvRZpcY4mpVHNI3EhF FS7ifIjQu91ElrceEnCt4xDk30/JJS1t7z7vHtgXr3ESv2qKMYaRdK5aex7AKfMQ0r2h HM1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2h0dLLCUZOiNdnFtLTsymdkgX1iFI50dFM6FVDv6Whg=; b=ja67Yw/DwZQw8mpvS1kTCjOVz8pdsezHwlCLe0hqt9e9ZcI8tmFC4CgpRVEuC335Nn qgQwAgpkUy2yyaJ9HTQBHDkaMAHEPVtdrHsi9eoruZIzkgAp0BEoyt+ia3t8pCjLh8Zy 8tDy6xkmBktDQthFOjGrx5JfmuOi69Da7UbXpIBQDJPp5m6rQmTh5IbCkohkbmnV9DAc IBjF7u8mQBnceWMhDa8zcBv3oqIpLCh4+TMghkMqZeCyi05+xVzzuSc1BXAV6mLdbJXe mJsjrcDzsTBOt0oImOjrFo7V9cbNor1V89mArOAZGBsuH6kg/RSPSh6oyMhVB/T1o0R6 Uziw== X-Gm-Message-State: APjAAAUPm6JUuMxMRtgCsf9G6YsIh0DkkCqNgABOVpsDQZzJ3I+1i/E2 aNkAFmcw9Cl7SiBr6PD2YfG4ZB+xMo46QkWEKaI= X-Google-Smtp-Source: APXvYqzyfvLmGqfTwAT0dYv2ZwB9T7/pnLCtHD5/qVoSM9m9WihJmFagQtTPPNsK+ZlwRt4R6y1tiDKESBb8Hv/RqBg= X-Received: by 2002:aca:43c4:: with SMTP id q187mr4699106oia.34.1553078439174; Wed, 20 Mar 2019 03:40:39 -0700 (PDT) MIME-Version: 1.0 References: <85417a73-a391-c9ad-49aa-5b88c65b0900@gmail.com> <5c8ea43d.1c69fb81.e50f1.7d18SMTPIN_ADDED_MISSING@mx.google.com> <0d34b3b1-866e-4bab-9a8f-3c70f1fc9721@www.fastmail.com> In-Reply-To: Date: Wed, 20 Mar 2019 10:40:27 +0000 Message-ID: To: Stanislav Malyshev Cc: Larry Garfield , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] RFC Draft: Comprehensions From: robehickman@gmail.com (Robert Hickman) >> Honestly, I cannot think of any case where I'd use a comprehension >> where I would definitely want an array and not a generator. In the >> majority case both work equally well, cool, but I don't know when I >> would even use an array-dependent version. >> And converting from a generator to an array is trivial; the other >> way, very not so much. > I don't think I ever used > the generator one in python (I use list one all the time), and I maybe > used analogous construct in PHP once or twice (and again I use array_map > and more complex syntax for array transformations all the time). > I use generator expressions rarely in python, usually as a conditional 'if any data in x match condition': if not next((True for flter in config['pull_ignore_filters'] if fnmatch.fnmatch(fle['path'], flter)), False): filtered_pull_files.append(fle) I use the list form for filtering, and the dict form mostly for creating an index of a sub-value as noted before. I don't use generators at all in PHP right now, but do make extensive use of loops doing filters and building indexes. An 'array comprehension' syntax would be welcome from me. One needs to be contentions that people use tools differently, so 'I don't use something' isn't the same as 'nobody uses something'.