Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.069 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'important,': 0.07; 'tests.': 0.07; 'subject:string': 0.09; 'cc:addr:python-list': 0.11; 'behavior,': 0.16; 'it),': 0.16; 'received:166.84': 0.16; 'received:166.84.1': 0.16; 'received:166.84.1.89': 0.16; 'received:mailbackend.panix.com': 0.16; 'received:panix.com': 0.16; 'roy': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'received:166': 0.19; 'things.': 0.19; 'seems': 0.21; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'driven': 0.24; "shouldn't": 0.24; 'initial': 0.24; '---': 0.24; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'testing': 0.29; 'correct': 0.29; 'am,': 0.29; 'important.': 0.30; 'code': 0.31; 'received:66': 0.35; "can't": 0.35; 'agree': 0.35; 'test': 0.35; 'but': 0.35; 'view,': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.36; 'short': 0.38; 'does': 0.39; 'sure': 0.39; 'space': 0.40; 'according': 0.40; 'easy': 0.60; 'results.': 0.60; 'worry': 0.60; 'first': 0.61; "you've": 0.63; 'making': 0.63; 'header:Message- Id:1': 0.63; 'protection': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'smith': 0.68; 'behavior': 0.77; 'complexity': 0.84; 'email addr:panix.com': 0.84; 'isolated': 0.84; 'me).': 0.84; '2013,': 0.91; 'optimum': 0.93; '2013': 0.98 Subject: Re: Splitting of string at an interval Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=us-ascii From: Roy Smith In-Reply-To: Date: Mon, 8 Apr 2013 11:37:28 -0400 Content-Transfer-Encoding: quoted-printable References: <5161e996$0$29995$c3e8da3$5496439d@news.astraweb.com> To: Arnaud Delobelle X-Mailer: Apple Mail (2.1283) Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365435457 news.xs4all.nl 6877 [2001:888:2000:d::a6]:36088 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43081 On Apr 8, 2013, at 11:10 AM, Arnaud Delobelle wrote: > On 8 April 2013 14:21, Roy Smith wrote: >=20 >> For a while, I was rabidly(*) into TDD (Test Driven Development). = The >> cycle I was using was, "Write a specification of a behavior, write a >> (failing) test for that behavior, then write the least possible = amount >> of code to make the test pass. Lather, Rinse, Repeat, Ship" >>=20 >> The "least possible" part is important. It makes sure the cycles = stay >> short (ideally, just a few minutes), and that you don't write any = code >> for which you don't have tests. >=20 > The least amount of code is often also not the best in terms of time > or space complexity. Does this mean you have to write tests for time > and space complexity as well? That's interesting, but I don't know of > tools to help do that (time complexity seems easy enough, but space > complexity seems tougher to me). If space and time complexity are important, then you need to write a = test for those things. If you have no test for them, then it's not = important and you shouldn't worry about it. At least according to the = TDD catechism :-) =46rom a somewhat less radical point of view, the first thing you want = to do is get the code to produce correct results. Once you've got that = (and a fully comprehensive test suite to prove it), then you can move on = to making it more efficient, and your test suite serves as protection = against behavior regressions. And, yes, I agree that testing for time and space complexity are not = trivial, because making accurate, repeatable, and isolated measurements = of those things is often surprisingly complicated. I can't help point = out, however, that if your initial implementation is to have your code = return a constant, it's pretty likely to be an optimum solution in both = time and space :-) --- Roy Smith roy@panix.com