[Python-Dev] Re: A proposal to modify `None` so that it hashes to a constant

2022-11-29 Thread Yoni Lavi
I stand by what I said, there is absolutely nothing disingenious about it. > Over on the Discuss threads, > you have made it clear that the primary reason why you want hash(None) > to return a constant value is so that set iteration order will be > consistent from one run to another. No, it's

[Python-Dev] Re: A proposal to modify `None` so that it hashes to a constant

2022-11-29 Thread Chris Angelico
On Wed, 30 Nov 2022 at 10:48, Steven D'Aprano wrote: > Let's consider a thought-experiment: suppose we agree to your proposal > to make hash(None) return a constant, but at the same time modify the > set iteration algorithm so that it starts from a different position each > time you iterate,

[Python-Dev] Re: A proposal to modify `None` so that it hashes to a constant

2022-11-29 Thread Christopher Barker
> it [randomising iteration order or sets] would also break the invariant that `repr(data) == repr(data)` but it is times like this that I feel that it would be worth it. But it wouldn't -- equality of sets doesn't depend on iteration order. And even if you are talking about other types (this

[Python-Dev] Re: A proposal to modify `None` so that it hashes to a constant

2022-11-29 Thread Steven D'Aprano
On Tue, Nov 29, 2022 at 08:51:09PM -, Yoni Lavi wrote: > It does make your argument invalid though, since it's based on this > assumption that I was asking for a requirement on iteration order > (e.g. like dict's iteration order = insertion order guarantee), which > is not the case. Yoni,

[Python-Dev] Re: A proposal to modify `None` so that it hashes to a constant

2022-11-29 Thread Yoni Lavi
It does make your argument invalid though, since it's based on this assumption that I was asking for a requirement on iteration order (e.g. like dict's iteration order = insertion order guarantee), which is not the case. Again, determinism means that given all input data and commands fed to a

[Python-Dev] Re: A proposal to modify `None` so that it hashes to a constant

2022-11-29 Thread Brett Cannon
On Mon, Nov 28, 2022 at 5:38 PM Steven D'Aprano wrote: > On Mon, Nov 28, 2022 at 11:13:34PM +, Oscar Benjamin wrote: > > On Mon, 28 Nov 2022 at 22:56, Brett Cannon wrote: > > > > That's actually by design. Sets are not meant to be deterministic > > > conceptually as they are essentially a

[Python-Dev] Re: A proposal to modify `None` so that it hashes to a constant

2022-11-29 Thread Yoni Lavi
Looks like it's just miscommunication. There is the original proposal I made, strictly about how None is ought to be hashed, and then there is the separate topic of changing the stability properties of iteration on sets, and whether that can be made with/without a performance regression...

[Python-Dev] Re: A proposal to modify `None` so that it hashes to a constant

2022-11-29 Thread Yoni Lavi
> I can't see any, but then I couldn't see the security consequences of > predictable string hashes until they were pointed out to me. So it would > be really good to have some security experts comment on whether this is > safe or not. I can't either. I can point out that the complexity attack