Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-11-20 Thread Adrian Zubarev via swift-evolution
@Nate: Just another pitch. Do we really want the DocumentValues to be a MutableCollection? There are default implementations like sort which would destroy the correctness of your unordered dictionary. IMO all mutating functionality should be added manually to DocumentValues to ensure that it

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-15 Thread Dave Abrahams via swift-evolution
on Fri Oct 14 2016, Paul Cantrell wrote: > A late-arriving strong +1 for me. The index-related stuff is elegant and much > needed. I’m surprised > to learn that dict.keys and dict.values are copies and not already > views! They are views. > Clearly they should be.

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-14 Thread Paul Cantrell via swift-evolution
A late-arriving strong +1 for me. The index-related stuff is elegant and much needed. I’m surprised to learn that dict.keys and dict.values are copies and not already views! Clearly they should be. Question: I hit a closely related performance wall just last week, doing something like this:

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-14 Thread Nate Cook via swift-evolution
> On Oct 13, 2016, at 1:28 AM, Dave Abrahams via swift-evolution > wrote: > > on Wed Oct 12 2016, Nate Cook > wrote: > >>> On Oct 12, 2016, at 9:32 AM, plx via swift-evolution >>>

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-13 Thread Dave Abrahams via swift-evolution
on Wed Oct 12 2016, Nate Cook wrote: >> On Oct 12, 2016, at 9:32 AM, plx via swift-evolution >> wrote: >> >> The issue addressed is real; I’m not sure this is the best approach. >> >> In particular, unless I’m missing something obvious,

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-13 Thread Dave Abrahams via swift-evolution
on Wed Oct 12 2016, Alexis wrote: > Just to clarify: It seems like the only ABI-affecting change here is the type > of keys/values. As you > note at the end of your proposal, this should just be > Dictionary.Keys/Dictionary.Values regardless > of whether we

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Dave Abrahams via swift-evolution
on Tue Oct 11 2016, Nate Cook wrote: > Introduction > > This proposal addresses significant unexpected performance gaps when using > dictionaries. It > introduces type-specific collections for a Dictionary instance's keys and > values properties. > > New

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Russ Bishop via swift-evolution
> On Oct 11, 2016, at 2:28 PM, Nate Cook via swift-evolution > wrote: > > Inefficient > Value Mutation > > Dictionary values can be modified through the keyed

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread plx via swift-evolution
I agree that at least for stdlib purposes there’s something that looks like an explicit choice to make in-place mutation *available*. What I was trying to explain is whether or not in-place mutation *happens* is a bit implicit. It’s one thing to say that the difference here is just an idiom

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Károly Lőrentey via swift-evolution
I believe the implementation of efficient in-place mutation is very explicit in the code -- it is done by implementing DictionaryValue’s subscript using a special “mutableAddressWithNativeOwner” addressor instead of a normal setter.

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Alexis via swift-evolution
Just to clarify: It seems like the only ABI-affecting change here is the type of keys/values. As you note at the end of your proposal, this should just be Dictionary.Keys/Dictionary.Values regardless of whether we implement this proposal or not, in which case this can be punted for Swift 4. It

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread plx via swift-evolution
Thanks for the quick reply; given that I’m quite wrong about the important mechanics I rescind my criticisms. I will say I care about this enough to reply because the inability to do in-place mutation of dictionary values has been an incredibly frustrating limitation and I’d just assumed the

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Nate Cook via swift-evolution
> On Oct 12, 2016, at 10:58 AM, Károly Lőrentey via swift-evolution > wrote: > > I think this is a lovely approach to solving this API design problem. > > One thing I don’t quite understand yet is how these kinds of mutable views > interact with copy on write

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Károly Lőrentey via swift-evolution
Ah, I see plx has already brought this up. So this is a bug in the implementation, and (presumably) DictionaryValue’s mutable subscript addressor is supposed to take care of COW semantics without introducing needless copying. (It’s too bad we aren’t supposed to use these magical addressors

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Károly Lőrentey via swift-evolution
I think this is a lovely approach to solving this API design problem. One thing I don’t quite understand yet is how these kinds of mutable views interact with copy on write semantics. COW rules can be subtle, and these views seem to put an extra twist on top that seems hard to

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Xiaodi Wu via swift-evolution
On Wed, Oct 12, 2016 at 10:31 AM, Nate Cook via swift-evolution < swift-evolution@swift.org> wrote: > Thanks for your feedback! Response below. > > On Oct 12, 2016, at 5:40 AM, Daniel Vollmer via swift-evolution < > swift-evolution@swift.org> wrote: > > Hi, > > I very much think the points

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Nate Cook via swift-evolution
Thanks for your feedback! Response below. > On Oct 12, 2016, at 5:40 AM, Daniel Vollmer via swift-evolution > wrote: > > Hi, > > I very much think the points mentioned in the motivation are worth addressing > (and IMO this is not an area where “maybe the optimizer

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Nate Cook via swift-evolution
> On Oct 12, 2016, at 9:32 AM, plx via swift-evolution > wrote: > > The issue addressed is real; I’m not sure this is the best approach. > > In particular, unless I’m missing something obvious, the ownership strategy > here would have to be: > > -

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread T.J. Usiyan via swift-evolution
+1 from me. Seems like a solid change. On Wed, Oct 12, 2016 at 12:39 AM, Jacob Bandes-Storch via swift-evolution < swift-evolution@swift.org> wrote: > +1. Haven't hit this issue personally, but I agree it's important and the > proposed solution seems like the right fix. > > On Tue, Oct 11, 2016

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Jean-Denis Muys via swift-evolution
A clear win for me. +1 > On 11 Oct 2016, at 23:28, Nate Cook via swift-evolution > wrote: > > Introduction > > This proposal addresses significant unexpected performance gaps when using > dictionaries. It introduces type-specific collections for a Dictionary >

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Stephan Knitelius via swift-evolution
+1 On Wed, 12 Oct 2016 at 09:09 Said Sikira via swift-evolution < swift-evolution@swift.org> wrote: > +1 > > > On October 12, 2016 at 8:54:45 AM, Rien via swift-evolution ( > swift-evolution@swift.org) wrote: > > Beautiful, +1 > > Rien > > > On 11 Oct 2016, at 23:28, Nate Cook via

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-12 Thread Said Sikira via swift-evolution
+1 On October 12, 2016 at 8:54:45 AM, Rien via swift-evolution ( swift-evolution@swift.org) wrote: Beautiful, +1 Rien > On 11 Oct 2016, at 23:28, Nate Cook via swift-evolution < swift-evolution@swift.org> wrote: > > Introduction > > This proposal addresses significant unexpected performance

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-11 Thread Jacob Bandes-Storch via swift-evolution
+1. Haven't hit this issue personally, but I agree it's important and the proposed solution seems like the right fix. On Tue, Oct 11, 2016 at 2:28 PM, Nate Cook via swift-evolution < swift-evolution@swift.org> wrote: > Introduction > > This proposal addresses significant unexpected performance

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-11 Thread Nate Cook via swift-evolution
> On Oct 11, 2016, at 5:06 PM, Braeden Profile wrote: > > Awesome; +1. Does this address the lack of .init(keys:values:)? Would it > make that addition easier? No, I don't think this has any bearing on that question. There's a separate proposal for that sort of

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-11 Thread Erica Sadun via swift-evolution
I agree. I like this proposal. -- E > On Oct 11, 2016, at 3:38 PM, Xiaodi Wu via swift-evolution > wrote: > > Very elegant solution. Strong +1; no other feedback comes to mind atm. > > > On Tue, Oct 11, 2016 at 4:28 PM, Nate Cook via swift-evolution >

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-11 Thread Braeden Profile via swift-evolution
Awesome; +1. Does this address the lack of .init(keys:values:)? Would it make that addition easier? > On Oct 11, 2016, at 3:38 PM, Xiaodi Wu via swift-evolution > wrote: > > Very elegant solution. Strong +1; no other feedback comes to mind atm. > > > On Tue, Oct

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-11 Thread Tony Allevato via swift-evolution
As someone who's hit this performance issue myself, a big +1 from me. The solution looks like it fits perfectly into Swift. On Tue, Oct 11, 2016 at 3:01 PM Matthew Johnson via swift-evolution < swift-evolution@swift.org> wrote: > Looks very nice. +1 here as well. > > On Oct 11, 2016, at 4:28

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-11 Thread Matthew Johnson via swift-evolution
Looks very nice. +1 here as well. > On Oct 11, 2016, at 4:28 PM, Nate Cook via swift-evolution > wrote: > > Introduction > > This proposal addresses significant unexpected performance gaps when using > dictionaries. It introduces type-specific collections for a

Re: [swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-11 Thread Xiaodi Wu via swift-evolution
Very elegant solution. Strong +1; no other feedback comes to mind atm. On Tue, Oct 11, 2016 at 4:28 PM, Nate Cook via swift-evolution < swift-evolution@swift.org> wrote: > Introduction > > This proposal addresses significant unexpected performance gaps when using > dictionaries. It introduces

[swift-evolution] [Proposal Draft] Provide Custom Collections for Dictionary Keys and Values

2016-10-11 Thread Nate Cook via swift-evolution
Introduction This proposal addresses significant unexpected performance gaps when using dictionaries. It introduces type-specific collections for a Dictionary instance's keys and values properties. New DictionaryKeys and DictionaryValues collections provide efficient key lookup and mutable