On Wed, Nov 28, 2018 at 3:54 PM Chris Angelico <[email protected]> wrote: > > On Thu, Nov 29, 2018 at 1:46 AM Jonathan Fine <[email protected]> wrote: > > > > On Wed, Nov 28, 2018 at 2:28 PM E. Madison Bray <[email protected]> > > wrote: > > > > > I mostly agree with the existing objections, though I have often found > > > myself wanting this too, especially now that `map` does not simply > > > return a list. This problem alone (along with the same problem for > > > filter) has had a ridiculously outsized impact on the Python 3 porting > > > effort for SageMath, and I find it really irritating at times. > > > > I'm a mathematician, so understand your concerns. Here's what I hope > > is a helpful suggestion. > > > > Create a module, say sage.itertools that contains (not tested) > > > > def py2map(iterable): > > return list(map(iterable)) > > With the nitpick that the arguments should be (func, *iterables) > rather than just the single iterable, yes, this is a viable transition > strategy. In fact, it's very similar to what 2to3 would do, except > that 2to3 would do it at the call site. If any Py3 porting process is > being held up significantly by this, I would strongly recommend giving > 2to3 an eyeball - run it on some of your code, then either accept its > changes or just learn from the diffs. It's not perfect (nothing is), > but it's a useful tool.
That effort is already mostly done and adding a helper function would not have worked as users *passing* map(...) as an argument to some function just expect it to work. The only alternative would have been replacing the builtin map with something else at the globals level. 2to3 is mostly useless since a major portion of Sage is written in Cython anyways. I just mentioned that porting effort for background. I still believe that the actual proposal of making the arguments to a map(...) call accessible from Python as attributes of the map object (ditto filter, zip, etc.) is useful in its own right, rather than just having this completely opaque iterator. _______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
