<div dir="ltr"><div dir="ltr">On Sun, Feb 3, 2019 at 3:54 AM Adrien Ricocotam <<a href="mailto:ricocotam@gmail.com">ricocotam@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I think all the issues you have right now would go of using another operation. I proposed the @ notation that is clear and different from everything else,<br></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>plus the operator is called "matmul" so it completely makes sense. The the examples would be :</div></div></blockquote><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>>>> <font face="monospace, monospace">l = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split()</font><br></div><div><font face="monospace, monospace"><font face="monospace, monospace">>>> v = Vector(l)</font></font></div><div><font face="monospace, monospace"><font face="monospace, monospace">>>> len(v)</font></font></div><div><font face="monospace, monospace"><font face="monospace, monospace">12</font></font></div><div><font face="monospace, monospace"><font face="monospace, monospace">>>> v @ len</font></font></div><div><font face="monospace, monospace"><font face="monospace, monospace"><font face="monospace, monospace"><Vector of [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]></font></font></font></div></div></blockquote><div><br></div><div>I cannot really see how using the @ operator helps anything here.  If this were a language that isn't Python (or conceivably some future version of Python, but that doesn't feel likely or desirable to me), I could imagine @ as an operator to vectorize any arbitrary sequence (or iterator).  But given that we've already made the sequence into a Vector, there's no need for extra syntax to say it should act in a vectorized way.</div><div><br></div><div>Moreover, your syntax is awkward for methods with arguments.  How would I spell:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div><font face="monospace, monospace">v.replace('foo', 'bar') </font></div></div></blockquote><div class="gmail_quote"><div><br></div><div>In the @ syntax? I actually made an error on my first pass where simply naming a method was calling it.  I thought about keeping it for a moment, but that really only allows zero argument calls.</div><div><br></div><div>I think the principled thing to do here is add the minimal number of methods to Vector itself, and have everything else pass through as vectorized calls.  Most of that minimal number are "magic method":  __len__(), __contains__(), __str__(), __repr__(), __iter__(), __reversed__().  I might have forgotten a couple.  All of those should not be called directly, normally, but act as magic for operators or built-in functions.</div><div><br></div><div>I think I should then create regular methods of the same name that perform the vectorized version.  So we would have:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><font face="monospace, monospace">len(v)   # -> 12</font></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><font face="monospace, monospace">v.len()  # -> <Vector of [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]></font></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="monospace, monospace">list(v)  # -> </font><span style="font-family:monospace,monospace">["Jan", "Feb", "Mar", "Apr", "May", "Jul" ...]<br>v.list() # -> </span><span style="font-family:monospace,monospace"><Vector of </span><font face="monospace, monospace" style="font-family:monospace,monospace"><font face="monospace, monospace"><font face="monospace, monospace">[["J", "a", "n"], ["F", "e", "b"] ... ></font></font></font></blockquote><div class="gmail_quote"><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I can't implement every single constructor that users might conceivably want, of course, but I can do it for the basic types in builtins and common standard library.  E.g. I might do:</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><span style="font-family:monospace,monospace">v.deque() # -> </span><span style="font-family:monospace,monospace"><Vector of </span><font face="monospace, monospace" style="font-family:monospace,monospace"><font face="monospace, monospace"><font face="monospace, monospace">[deque(["J", "a", "n"]), deque(["F", "e", "b"]) ... ></font></font></font></blockquote><div class="gmail_quote"><br class="gmail-Apple-interchange-newline"></div></div><div class="gmail_quote">But I certainly won't manually add:</div><div class="gmail_quote"><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div class="gmail_quote"><font face="monospace, monospace">v.custom_linked_list()  # From my_inhouse_module.py</font></div></div></blockquote><div class="gmail_quote"><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">Hmm... maybe even I could look at names of maybe-constructors in the current namespace and try them.  That starts to feel too magic.  Falling back to this feels better:</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_quote"><div class="gmail_quote"><font face="monospace, monospace">map(</font><span style="font-family:monospace,monospace">custom_linked_list, </span><span style="font-family:monospace,monospace">v)  # From my_inhouse_module.py</span></div></div></blockquote><div class="gmail_quote"><br class="gmail-Apple-interchange-newline"></div></div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div></div>