On Fri, Jul 26, 2019 at 7:47 AM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > > Batuhan Taskaya wrote: > > I think it looks very fine when you type {1, 2, 3} * {"a", "b", "c"} and > > get set(itertools.product({1, 2, 3}, {"a", "b", "c"})). So i am > > proposing set multiplication implementation as cartesian product. > > I'm not sure this would be used frequently enough to justify making it > a built-in operation on sets. I can't think of any situation where I've > wanted to materialise a Cartesian product as an actual set object. > Usually I'm iterating over it and doing something else, and we already > have more flexible ways of doing that -- list comprehensions, nested > loops, etc. > > Also, this would really only work sensibly for Cartesian products of > two sets, not three or more. Writing s1 * s2 * s3 wouldn't give you > a set of 3-tuples (a, b, c), but a set of 2-tuples ((a, b), c). > Mathematicians usually gloss over this distinction, but in programming > it becomes important. >
Both could be solved if the product of a set and a set was a "Cartesian product" object that just retains an iterator on each. Still not sure how necessary it is, but I'm no mathematician. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4GNCYSMF2Q6B4D7446XTXPIMMCAPG4G2/ Code of Conduct: http://python.org/psf/codeofconduct/