Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: =?UTF-8?Q?Nagy_L=c3=a1szl=c3=b3_Zsolt?= Newsgroups: comp.lang.python Subject: Re: Set type for datetime intervals Date: Mon, 4 Apr 2016 09:16:55 +0200 Lines: 27 Message-ID: References: <56FE0625.5030901@shopzeus.com> <570214E7.8040101@shopzeus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de WjtjKMpUfosMhTnJZdywbge3S3H5rzFe0kTY3oSyBDMg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'url:pypi': 0.03; 'builtin': 0.07; 'difference,': 0.07; 'implements': 0.07; 'def': 0.13; '2016': 0.16; 'pypi?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:type': 0.16; 'symmetric': 0.16; 'url:submit': 0.16; 'wrote:': 0.16; 'implementing': 0.18; 'library': 0.20; 'to:name:python-list@python.org': 0.20; 'to:2**1': 0.21; 'sets': 0.23; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'resolution': 0.28; 'operations': 0.31; 'anyone': 0.32; 'url:python': 0.33; 'ones': 0.35; 'clear': 0.35; 'url:%3a': 0.35; 'but': 0.36; 'needed': 0.36; 'there': 0.36; 'url:org': 0.36; 'url:action': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'does': 0.39; 'to:addr:python.org': 0.40; 'skip:n 10': 0.62; 'request.': 0.66; 'url:search': 0.83; 'nagy': 0.84; 'stop,': 0.84; 'subject:Set': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopzeus.com; s=shopzeus_com; t=1459754212; bh=YOZi+71nfKhpeLVgYTncl+4kijluk0IDJPZaxkNuAwg=; h=Subject:To:References:From:Date:In-Reply-To:From; b=F4UxGNZ6ATtFWo0Epff+nPyaL2sgQoaH69ASNPXPf8/WZo/VZxnEA7MRdoKjHT5OL NAGoMrl+kLIxiLqKykFkLTcz7O+ZrNSO9UL7F+d4/Ku9VC2u60XaaDIG5Y+3Fut3Sb Dh2PHzvv8B3yaRO2kw1c8iKCnc8wVXwNAqLnDXNwRZlSvoNt+6G71i3aU6VlbUSQ00 bIlDZ9JHyMdvLvD73VHp/l9bMt8NXdjGYRUnWnQLVRNv5RBM8sXEzlKVVSLl0Qh+0K KZ88brQFLZoEPdLxszIhBrBHfKB9C9eXNr8ErBQae2UXCvVEEjg2FxIgVIu8hLmpO8 s7JtoNv17/4Ig== In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <570214E7.8040101@shopzeus.com> X-Mailman-Original-References: <56FE0625.5030901@shopzeus.com> Xref: csiph.com comp.lang.python:106426 > > On Fri, Apr 1, 2016 at 1:32 AM Nagy László Zsolt > wrote: > > Does anyone know a library that already implements these functions? > > > What do you not like about the ones on PyPI? > https://pypi.python.org/pypi?%3Aaction=search&term=interval&submit=search There are a few, but none of them was implementing a set ot non-intersecting intervals. AFAIK what I needed had no implementation until now. > > Depending on the resolution you want, you might be able to use builtin > sets for everything. > > def interval(start, stop, precision=60): > a = round(start.timestamp(), precision) > b = round(stop.timestamp(), precision) > return set(range(a, b, precision)) > I know, I was not clear in my request. A simple set will not unify overlapping intervals, and cannot do set operations (union, intersection, difference, symmetric difference).