Re: [Python-ideas] namedtuple with ordereddict

2017-07-18 Thread Serhiy Storchaka
19.07.17 01:33, Greg Ewing пише: Jim J. Jewett wrote: is there any reason not to simply define it as a view on a dict, or at least as a limited proxy to one? Some valuable characteristics of namedtuples as they are now: * Instances are very lightweight * Access by index is fast * Can be used

Re: [Python-ideas] Enabling Event.set to notify all waiters with an exception

2017-07-18 Thread Pau Freixes
Yeps, > 'Event' is designed as a lowish-level primitive: the idea is that it > purely provides the operation of "waiting for something", and then you > can compose it with other data structures to build whatever > higher-level semantics you need. From this point of view, it doesn't > make much se

Re: [Python-ideas] Alternative Unicode implementations (NSString/NSMutableString)

2017-07-18 Thread Ronald Oussoren
> On 19 Jul 2017, at 00:35, Jim J. Jewett wrote: > > Ronald Oussoren came up with a concrete use case for wanting the > interpreter to consider something a string, even if it isn't > implemented with the default datastructure. > > In https://mail.python.org/pipermail/python-ideas/2017-July/0464

Re: [Python-ideas] Alternative Unicode implementations (NSString/NSMutableString)

2017-07-18 Thread Nick Coghlan
On 19 July 2017 at 09:40, Victor Stinner wrote: > Supporting a new kind of string storage would require a lot of efforts. > There are a lot of C code specialized for each Unicode kind If I understand the requested flag correctly, it would be to request one of the following: 1. *Never* use any of

Re: [Python-ideas] between block and function [was: Custom Code Folding: Standardized Rules and Syntax?]

2017-07-18 Thread Steven D'Aprano
On Tue, Jul 18, 2017 at 09:13:11PM -0400, Jim J. Jewett wrote: > There have been times when I wanted to group portions of a module, > class, or function. Giving names to each of those groupings would be > useful, and would be appropriate for python-level changes. I don't know about grouping parts

Re: [Python-ideas] pathlib.Path should handle Pythonpath or package root

2017-07-18 Thread Nick Coghlan
On 19 July 2017 at 06:40, George Fischhof wrote: > I think yes ;-) > I would like to use (or I think it would be good to use) something like > pathlib.Path(package_root) > so I could use > > importlib.import_module(pathlib.Path(package_root) / plugins / plugin_name) No, as that's fundamentally in

Re: [Python-ideas] namedtuple with ordereddict

2017-07-18 Thread Steven D'Aprano
On Tue, Jul 18, 2017 at 06:16:26PM -0400, Jim J. Jewett wrote: > Given that > > (1) dicts now always pay the price for ordering > (2) namedtuple is being accelerated > > is there any reason not to simply define it as a view on a dict, or at > least as a limited proxy to one? Tuples are much more

[Python-ideas] between block and function [was: Custom Code Folding: Standardized Rules and Syntax?]

2017-07-18 Thread Jim J. Jewett
There have been times when I wanted to group portions of a module, class, or function. Giving names to each of those groupings would be useful, and would be appropriate for python-level changes. That said, it would probably need more proof in the wild first, so the first step would be getting sup

Re: [Python-ideas] Alternative Unicode implementations (NSString/NSMutableString)

2017-07-18 Thread Victor Stinner
Supporting a new kind of string storage would require a lot of efforts. There are a lot of C code specialized for each Unicode kind Victor Le 19 juil. 2017 12:43 AM, "Jim J. Jewett" a écrit : > Ronald Oussoren came up with a concrete use case for wanting the > interpreter to consider something

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Guido van Rossum
On Tue, Jul 18, 2017 at 3:18 PM, Greg Ewing wrote: > Ethan Furman wrote: > >> I certainly don't expect the signature to change, but why is using a >> metaclass out? The use (or not) of a metaclass /is/ an implementation >> detail. >> > > For me, the main benefit of using a metaclass would be tha

[Python-ideas] Alternative Unicode implementations (NSString/NSMutableString)

2017-07-18 Thread Jim J. Jewett
Ronald Oussoren came up with a concrete use case for wanting the interpreter to consider something a string, even if it isn't implemented with the default datastructure. In https://mail.python.org/pipermail/python-ideas/2017-July/046407.html he writes: The reason I need to subclass str: in PyO

Re: [Python-ideas] namedtuple with ordereddict

2017-07-18 Thread Greg Ewing
Jim J. Jewett wrote: is there any reason not to simply define it as a view on a dict, or at least as a limited proxy to one? Some valuable characteristics of namedtuples as they are now: * Instances are very lightweight * Access by index is fast * Can be used as a dict key All of those would

Re: [Python-ideas] Enabling Event.set to notify all waiters with an exception

2017-07-18 Thread Nathaniel Smith
On Tue, Jul 18, 2017 at 2:33 PM, Pau Freixes wrote: > Morning guys, (Not everyone here is a guy.) > I came across with that idea trying to resolve a typical dogpile > pattern [1], having many DNS calls to the same domain because of a > miss in a DNS cache. > > The usage of the the set either to

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Greg Ewing
Ethan Furman wrote: I certainly don't expect the signature to change, but why is using a metaclass out? The use (or not) of a metaclass /is/ an implementation detail. For me, the main benefit of using a metaclass would be that it enables using normal class declaration syntax to define a named

[Python-ideas] namedtuple with ordereddict

2017-07-18 Thread Jim J. Jewett
Given that (1) dicts now always pay the price for ordering (2) namedtuple is being accelerated is there any reason not to simply define it as a view on a dict, or at least as a limited proxy to one? Then constructing a specific instance from the arguments used to create it could be as simple as

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Ethan Furman
On 07/18/2017 09:09 AM, Guido van Rossum wrote: On Tue, Jul 18, 2017 at 8:56 AM, Ethan Furman wrote: I certainly don't expect the signature to change, but why is using a metaclass out? The use (or not) of a metaclass /is/ an implementation detail. It is until you try to subclass with anoth

[Python-ideas] Enabling Event.set to notify all waiters with an exception

2017-07-18 Thread Pau Freixes
Morning guys, I came across with that idea trying to resolve a typical dogpile pattern [1], having many DNS calls to the same domain because of a miss in a DNS cache. The usage of the the set either to notify that the waiters could be awake and get the result from the cache or use it to notify th

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Joao S. O. Bueno
In the other thread, I had mentioned my "extradict" implementation - it does have quite a few differences as it did not try to match namedtuple API, but it works nicely for all common use cases - these are the timeit timings: (env) [gwidion@caylus ]$ python3 -m timeit --setup "from collections imp

Re: [Python-ideas] pathlib.Path should handle Pythonpath or package root

2017-07-18 Thread George Fischhof
2017-07-18 15:56 GMT+02:00 Nick Coghlan : > On 18 July 2017 at 22:08, George Fischhof wrote: > > Hi there, > > > > I created a program which uses plugins (import them). I started to test > it, > > and found that I need two types of paths: one for file system and another > > one which is package r

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Ethan Furman
On 07/17/2017 09:06 PM, David Mertz wrote: On Jul 17, 2017 7:56 PM, "Ethan Furman" mailto:et...@stoneleaf.us>> wrote: On 07/17/2017 06:34 PM, Steven D'Aprano wrote: On Mon, Jul 17, 2017 at 05:01:58PM -0700, Ethan Furman wrote: Guido has decreed that namedtuple shall be

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Guido van Rossum
On Tue, Jul 18, 2017 at 8:56 AM, Ethan Furman wrote: > I certainly don't expect the signature to change, but why is using a > metaclass out? The use (or not) of a metaclass /is/ an implementation > detail. > It is until you try to subclass with another metaclass -- then you have a metaclass con

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Ethan Furman
On 07/17/2017 06:25 PM, Eric Snow wrote: On Mon, Jul 17, 2017 at 6:01 PM, Ethan Furman wrote: Guido has decreed that namedtuple shall be reimplemented with speed in mind. FWIW, I'm sure that any changes to namedtuple will be kept as minimal as possible. Changes would be limited to the under

Re: [Python-ideas] pathlib.Path should handle Pythonpath or package root

2017-07-18 Thread Nick Coghlan
On 18 July 2017 at 22:08, George Fischhof wrote: > Hi there, > > I created a program which uses plugins (import them). I started to test it, > and found that I need two types of paths: one for file system and another > one which is package relative. > > So I thing this is a good idea, to enhance p

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Nick Coghlan
On 18 July 2017 at 14:31, Guido van Rossum wrote: > On Mon, Jul 17, 2017 at 6:25 PM, Eric Snow > wrote: >> >> On Mon, Jul 17, 2017 at 6:01 PM, Ethan Furman wrote: >> > Guido has decreed that namedtuple shall be reimplemented with speed in >> > mind. >> >> FWIW, I'm sure that any changes to named

Re: [Python-ideas] tempfile.TemporaryDirectory() should be able to create temporary directory at a given arbitrary place

2017-07-18 Thread Steven D'Aprano
On Tue, Jul 18, 2017 at 01:55:15PM +0200, George Fischhof wrote: > Hi there, > > I used tempfile.TemporaryDirectory(). On first usage it was good, but on > second one there was a need to create tempopray directory and files in it a > given place. (It needed for a test). > > And I found that Tempo

Re: [Python-ideas] tempfile.TemporaryDirectory() should be able to create temporary directory at a given arbitrary place

2017-07-18 Thread George Fischhof
2017-07-18 14:06 GMT+02:00 Serhiy Storchaka : > 18.07.17 14:55, George Fischhof пише: > >> I used tempfile.TemporaryDirectory(). On first usage it was good, but on >> second one there was a need to create tempopray directory and files in it a >> given place. (It needed for a test). >> >> And I fou

[Python-ideas] pathlib.Path should handle Pythonpath or package root

2017-07-18 Thread George Fischhof
Hi there, I created a program which uses plugins (import them). I started to test it, and found that I need two types of paths: one for file system and another one which is package relative. So I thing this is a good idea, to enhance pathlib to handle package roots. (I know about sys.path, envir

Re: [Python-ideas] tempfile.TemporaryDirectory() should be able to create temporary directory at a given arbitrary place

2017-07-18 Thread Serhiy Storchaka
18.07.17 14:55, George Fischhof пише: I used tempfile.TemporaryDirectory(). On first usage it was good, but on second one there was a need to create tempopray directory and files in it a given place. (It needed for a test). And I found that TemporaryDirectory() is not able to do this. So my id

[Python-ideas] tempfile.TemporaryDirectory() should be able to create temporary directory at a given arbitrary place

2017-07-18 Thread George Fischhof
Hi there, I used tempfile.TemporaryDirectory(). On first usage it was good, but on second one there was a need to create tempopray directory and files in it a given place. (It needed for a test). And I found that TemporaryDirectory() is not able to do this. So my idea is to implement this behavio