[Python-ideas] Re: dict_items.__getitem__?

2021-10-05 Thread Alexander Hill
> Except many iterables don’t have a last item. And many more can’t give you the last item efficiently. That's manageable - reversed won't work either unless the object either implements either __reversed__, or __len__ and __getitem__. last could simply fail under the same conditions, in which

[Python-ideas] Re: What about having a .get(index, default) method for arrays like we have for dicts?

2020-06-30 Thread Alexander Hill
toolz.get_in is designed for exactly this. https://toolz.readthedocs.io/en/latest/api.html#toolz.dicttoolz.get_in The whole library is great! Alex On Wed, 1 Jul 2020 at 8:03 am, MRAB wrote: > On 2020-06-30 23:26, Daniel. wrote: > > I just want to make clear that safe navegator is enough to

[Python-ideas] Re: Support infinite temporal types

2020-06-17 Thread Alexander Hill
I've just updated my implementation to support multiplication and division of TIMEDELTA_INF, mimicking the behaviour of timedelta and float("inf"). Cheers, Alex On Wed, Jun 17, 2020 at 8:26 PM Alexander Hill wrote: > 1. Dates beyond year aren't a prerequisite for infinite

[Python-ideas] Re: Support infinite temporal types

2020-06-17 Thread Alexander Hill
medelta(days=1)` raises TypeError (the latter returns nan in the case of float). Thanks, Alex On Wed, Jun 17, 2020 at 2:57 PM Serhiy Storchaka wrote: > 16.06.20 13:54, Alexander Hill пише: > > I’d like to propose support for infinite dates, datetimes and > > timedeltas. They

[Python-ideas] Re: Support infinite temporal types

2020-06-17 Thread Alexander Hill
better to have one version in > the stdlib. > > I haven't had a chance to review your implementation, but if it looks like > you're getting support, I'll be sure to do so. > > -CHB > > > > On Tue, Jun 16, 2020 at 5:45 AM Alexander Hill wrote: > >> Hi all

[Python-ideas] Support infinite temporal types

2020-06-16 Thread Alexander Hill
Hi all, I’d like to propose support for infinite dates, datetimes and timedeltas. They're very useful when you need to model ranges with one or both ends unbounded (e.g. “forever starting from June 15th 2020”). Without first-class infinite values, you can use None, or you can use the `min` and