[Python-ideas] Vectorization [was Re: Add list.join() please]
David Mertz
mertz at gnosis.cx
Fri Feb 8 15:35:31 EST 2019
On Fri, Feb 8, 2019 at 3:17 PM Christopher Barker <pythonchb at gmail.com>
wrote:
> > vec_seq = Vector(seq)
> > (vec_seq * 2).name.upper()
> > # ... bunch more stuff
> > seq = vec_seq.unwrap()
>
> what type would .unwrap() return?
>
The idea—and the current toy implementation/alpha—has .unwrap return
whatever type went into the Vector creation. Might be a tuple, list, set,
deque, or it might be an iterator. It might even be some custom collection
that isn't in the standard library.
But you can also explicitly make a Vector into something else by using that
constructor. Pretty much as I gave example before:
set(Vector(a_list)) # Get a set
Vector(a_list)).unwrap() # Get a list (without needing to know type
to call .unwrap())
--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190208/8222ddcf/attachment.html>
More information about the Python-ideas
mailing list