Movatterモバイル変換
[0]ホーム
[Python-ideas] Adding "Typed" collections/iterators to Python
Nick Coghlanncoghlan at gmail.com
Mon Dec 19 06:44:52 CET 2011
On Mon, Dec 19, 2011 at 2:47 PM, Nathan Rice<nathan.alexander.rice at gmail.com> wrote:> Regardless, I'm sure everything that gets added to the> language was first a hugely popular PyPI project, that is clearly the> way the language evolves.Not everything, no. The real criteria is to have solid use cases wherea proposal clearly improves the language. Sometimes that's justobvious (e.g. supporting a popular new compression protocol),sometimes a PEP is enough to explain, other times real worldexperience on PyPI is the best option. You don't have *any* of thoseat this point (just some vague hand-waving), so publishing a PyPIpackage is the most obvious way to start acquiring more data (and toprove that there's even a version of the idea that can be taken beyondthe hand-waving stage).What you seem to be asking for is a general purpose typed containerfactory along the following lines: def typed_container(container_type, data_type): class TypedContainer(container_type): def __getattr__(self, attr): data_type_attr = getattribute(data_type, attr) if callable(data_type_attr): _result_type = type(self) def _broadcast(*args, **kwds): _result_type(data_type_attr(x, *args, **kwds)for x in self) return _broadcast return data_type_attr return TypedContainerI think it will have a lot of problems in practice (note that NumPydoesn't try to solve the broadcasting problem in general, just for asingle specific data type), but, if the concept has any merit at all,that's certainly something that can be demonstrated quite adequatelyon PyPI.To get a better idea of the level of evidence you're trying to reachif your suggestion is ever going to get anywhere, try taking a look athttp://www.boredomandlaziness.org/2011/02/justifying-python-language-changes.htmlandhttp://www.boredomandlaziness.org/2011/02/status-quo-wins-stalemate.html.Cheers,Nick.-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideasmailing list
[8]ページ先頭