Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Marko Ristin-Kaufmann
Hi Chris, In other words, you change the *public interface* of your functions > all the time? How do you not have massive breakage all the time? I suppose that Pycharm helps the most with its refactoring tools. We use type annotations, contracts, static checks (mypy, pylint, pydocstyle) and

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Marko Ristin-Kaufmann
Hi, I'd like to share a use pattern for contracts that might have got lost in the discussion and which I personally grow to like more and more. I'm not making any claims; this use pattern work for our team and I can't judge how much of a benefit it would be to others. Imagine there are two

[Python-ideas] support toml for pyproject support

2018-10-08 Thread Jimmy Girardet
Hi, I don't know if this was already debated  but I don't know how to search in the whole archive of the list. For  now the  adoption of pyproject.toml file is more difficult because toml is not in the standard library. Each tool which wants to use pyproject.toml has to add a toml lib  as a

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread Nathaniel Smith
On Mon, Oct 8, 2018 at 2:55 AM, Steven D'Aprano wrote: > > On Mon, Oct 08, 2018 at 09:10:40AM +0200, Jimmy Girardet wrote: >> Each tool which wants to use pyproject.toml has to add a toml lib as a >> conditional or hard dependency. >> >> Since toml is now the standard configuration file format,

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Steven D'Aprano
On Mon, Oct 08, 2018 at 04:29:34PM +1100, Chris Angelico wrote: > On Mon, Oct 8, 2018 at 4:26 PM Marko Ristin-Kaufmann > wrote: > >> Not true for good docstrings. We very seldom change the essential > >> meaning of public functions. > > > > In my team, we have a stale docstring once every two

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Ram Rachum
I'm not an expert on memory. I used Process Explorer to look at the Process. The Working Set of the current run is 11GB. The Private Bytes is 708MB. Actually, see all the info here: https://www.dropbox.com/s/tzoud028pzdkfi7/screenshot_TURING_2018-10-08_133355.jpg?dl=0 I've got 16GB of RAM on this

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread Steven D'Aprano
Hi Jimmy, and welcome, On Mon, Oct 08, 2018 at 09:10:40AM +0200, Jimmy Girardet wrote: > Hi, > > I don't know if this was already debated  but I don't know how to search > in the whole archive of the list. > > > For  now the  adoption of pyproject.toml file is more difficult because > toml is

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Ram Rachum
That's incredibly interesting. I've never used mmap before. However, there's a problem. I did a few experiments with mmap now, this is the latest: path = pathlib.Path(r'P:\huge_file') with path.open('r') as file: mmap = mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) for match in

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Chris Angelico
On Mon, Oct 8, 2018 at 9:26 PM Steven D'Aprano wrote: > > In other words, you change the *public interface* of your functions > > all the time? How do you not have massive breakage all the time? > > I can't comment about Marko's actual use-case, but *in general* > contracts are aimed at

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Cameron Simpson
On 08Oct2018 10:56, Ram Rachum wrote: That's incredibly interesting. I've never used mmap before. However, there's a problem. I did a few experiments with mmap now, this is the latest: path = pathlib.Path(r'P:\huge_file') with path.open('r') as file: mmap = mmap.mmap(file.fileno(), 0,

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread Erik Bray
On Mon, Oct 8, 2018 at 12:23 PM Nathaniel Smith wrote: > > On Mon, Oct 8, 2018 at 2:55 AM, Steven D'Aprano wrote: > > > > On Mon, Oct 08, 2018 at 09:10:40AM +0200, Jimmy Girardet wrote: > >> Each tool which wants to use pyproject.toml has to add a toml lib as a > >> conditional or hard

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Marko Ristin-Kaufmann
Hi Crhis, > In other words, you change the *public interface* of your functions > > all the time? How do you not have massive breakage all the time? > > I can't comment about Marko's actual use-case, but *in general* > contracts are aimed at application *internal* interfaces, not so much >

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Anders Hovmöller
>> However, another possibility is the the regexp is consuming lots of memory. >> >> The regexp seems simple enough (b'.'), so I doubt it is leaking memory like >> mad; I'm guessing you're just seeing the OS page in as much of the file as it >> can. > > Yup. Windows will aggressively fill up

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Ram Rachum
" Windows will aggressively fill up your RAM in cases like this because after all why not? There's no use to having memory just sitting around unused." Two questions: 1. Is the "why not" sarcastic, as in you're agreeing it's a waste? 2. Will this be different on Linux? Which command do I run on

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread Anders Hovmöller
>> He's referring to PEPs 518 and 517 [1], which indeed standardize on >> TOML as a file format for Python package build metadata. >> >> I think moving anything into the stdlib would be premature though – >> TOML libraries are under active development, and the general trend in >> the packaging

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Erik Bray
On Mon, Oct 8, 2018 at 12:20 PM Cameron Simpson wrote: > > On 08Oct2018 10:56, Ram Rachum wrote: > >That's incredibly interesting. I've never used mmap before. > >However, there's a problem. > >I did a few experiments with mmap now, this is the latest: > > > >path = pathlib.Path(r'P:\huge_file')

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Steven D'Aprano
On Mon, Oct 08, 2018 at 09:32:23PM +1100, Chris Angelico wrote: > On Mon, Oct 8, 2018 at 9:26 PM Steven D'Aprano wrote: > > > In other words, you change the *public interface* of your functions > > > all the time? How do you not have massive breakage all the time? > > > > I can't comment about

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Ram Rachum
Thanks for your help everybody! I'm very happy to have learned about mmap. On Mon, Oct 8, 2018 at 3:27 PM Richard Damon wrote: > On 10/8/18 8:11 AM, Ram Rachum wrote: > > " Windows will aggressively fill up your RAM in cases like this > > because after all why not? There's no use to having

Re: [Python-ideas] Debugging: some problems and possible solutions

2018-10-08 Thread Rhodri James
On 04/10/18 19:10, Jonathan Fine wrote: In response to my problem-solution pair (fixing a typo) TITLE: Debug print() statements cause doctests to fail Rhodri James wrote: Or write your debug output to stderr? Perhaps I've been too concise. If so, I apologise. My proposal is that the system

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Richard Damon
On 10/8/18 8:11 AM, Ram Rachum wrote: > " Windows will aggressively fill up your RAM in cases like this > because after all why not?  There's no use to having memory just > sitting around unused." > > Two questions: > > 1. Is the "why not" sarcastic, as in you're agreeing it's a waste? > 2. Will

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread David Mertz
I agree here. I briefly urged against using the less used TOML format, but I have no real skin in the game around packaging. I like YAML, but that's also not in the standard library, even if more widely used. But given that packaging is committed to TOML, I think that's a strong case for

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread Pradyun Gedam
On Mon, Oct 8, 2018 at 12:49 PM Jimmy Girardet wrote: > > Hi, Hi Jimmy and welcome! :) > > I don't know if this was already debated but I don't know how to search > in the whole archive of the list. > > > For now the adoption of pyproject.toml file is more difficult because > toml is not in

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread Guido van Rossum
On Mon, Oct 8, 2018 at 4:53 AM Erik Bray wrote: > If I had the energy to argue it I would also argue against using TOML > in those PEPs. I personally don't especially care for TOML and what's > "obvious" to Tom is not at all obvious to me. I'd rather just stick > with YAML or perhaps something

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Chris Angelico
On Mon, Oct 8, 2018 at 11:11 PM Steven D'Aprano wrote: > > On Mon, Oct 08, 2018 at 09:32:23PM +1100, Chris Angelico wrote: > > On Mon, Oct 8, 2018 at 9:26 PM Steven D'Aprano wrote: > > > > In other words, you change the *public interface* of your functions > > > > all the time? How do you not

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Steven D'Aprano
On Sun, Oct 07, 2018 at 04:24:58PM -0400, Terry Reedy wrote: > A mathematical function is defined or specified by a input domain, > output range, and a mapping from inputs to outputs. The mapping can be > defined either by an explicit listing of input-output pairs or by a rule > specifying

Re: [Python-ideas] Better error messages for missing optional stdlib packages

2018-10-08 Thread Marcus Harnisch
On 10/08/2018 12:29 AM, Terry Reedy wrote: On 10/3/2018 4:29 PM, Marcus Harnisch wrote: When trying to import lzma on one of my machines, I was suprised to get a normal import error like for any other module. What was the traceback and message?  Did you get an import error for one of the

[Python-ideas] Introduce typing.SupportsFsPath

2018-10-08 Thread robert . hoelzl
Hello, Since __fspath__ was introduced in PEP 519 it is possible to create object classes that are representing file system paths. But there is no corresponding type object in the "typing" module. Thus I cannot specify functions, that accept any kind of object which supports the __fspath__

Re: [Python-ideas] Introduce typing.SupportsFsPath

2018-10-08 Thread Guido van Rossum
In typeshed there is os.PathLike which is close. You should be able to use Union[str, os.PathLike[str]] for what you want (or define an alias). We generally don't want to add more things to typing that aren't closely related to the type system. (Adding the io and re classes was already less than

Re: [Python-ideas] Support parsing stream with `re`

2018-10-08 Thread Chris Angelico
On Mon, Oct 8, 2018 at 11:15 PM Anders Hovmöller wrote: > > > However, another possibility is the the regexp is consuming lots of memory. > > The regexp seems simple enough (b'.'), so I doubt it is leaking memory like > mad; I'm guessing you're just seeing the OS page in as much of the file as it

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Marko Ristin-Kaufmann
Hi Chris, I hope you don't mind me responding though you would like to stop participating. This message is meant for other readers in case they are interested. > Alice tests her package A with some test data D_A. Now assume Betty did > not write any contracts for her package B. When Alice tests

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Steven D'Aprano
On Tue, Oct 09, 2018 at 01:21:57AM +1100, Chris Angelico wrote: > > > Yet we keep having use-cases shown to us involving one person with one > > > module, and another person with another module, and the interaction > > > between the two. > > > > Do we? I haven't noticed anything that matches that

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-10-08 Thread Terry Reedy
On 10/8/2018 10:26 AM, Steven D'Aprano wrote: On Sun, Oct 07, 2018 at 04:24:58PM -0400, Terry Reedy wrote: https://www.win.tue.nl/~wstomv/edu/2ip30/references/design-by-contract/index.html defines contracts as "precise (legally unambiguous) specifications" (5.2 Business

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-08 Thread Amjad Ben Hedhili
> Summary: Python's timeit.timeit() has an undocumented feature / > implementation detail that gives much of what the original poster has > asked for. Perhaps revising the docs will solve the problem. although timeit can be used with a callable, you need to create a lambda expression if the