Re: [Python-Dev] compatibility for C-accelerated types

2015-10-17 Thread Serhiy Storchaka
On 18.10.15 01:20, Eric Snow wrote: On the tracker he notes another OrderedDict compatibility break: Backward compatibility related to __class__ assignment was already broken in C implementation. In 3.4 following code works: >>> from collections import * >>> class

Re: [Python-Dev] PEP 506 secrets module

2015-10-17 Thread Guido van Rossum
Yes, randrange(n) does that. --Guido (mobile) On Oct 17, 2015 2:28 PM, "Brian Gladman" wrote: > > Guido van Rossum wrote: > > > I'm fine with dropping the 3rd arg. But I find the argument to > > introduce a new spelling for 1-arg randrange() weak. > > I should stress that

Re: [Python-Dev] PEP 506 secrets module

2015-10-17 Thread Guido van Rossum
OK, so just randbelow() then. --Guido (mobile) On Oct 17, 2015 2:13 PM, "Tim Peters" wrote: > [Steven D'Aprano] > >> ... > >> I think it is fair to say that out of the three functions, there is > >> consensus that randbelow has the most useful functionality in a crypto >

[Python-Dev] compatibility for C-accelerated types

2015-10-17 Thread Eric Snow
A recent discussion in a tracker issue [1] brought up the matter of compatibility between the pure Python implementation of OrderedDict and the new C implementation. In working on that port I stuck as closely as possible to the Python implementation. This meant some parts of the code are bit

Re: [Python-Dev] type(obj) vs. obj.__class__

2015-10-17 Thread Serhiy Storchaka
On 18.10.15 00:45, Eric Snow wrote: In a recent tracker issue about OrderedDict [1] we've had some discussion about the use of type(od) as a replacement for od.__class__. It came up because the pure Python implementation of OrderedDict uses self.__class__ in 3 different methods (__repr__,

Re: [Python-Dev] type(obj) vs. obj.__class__

2015-10-17 Thread Steven D'Aprano
On Sat, Oct 17, 2015 at 03:45:19PM -0600, Eric Snow wrote: > In a recent tracker issue about OrderedDict [1] we've had some > discussion about the use of type(od) as a replacement for > od.__class__. [...] > The more general question of when we use type(obj) vs. obj.__class__ > applies to both

Re: [Python-Dev] PEP 506 secrets module

2015-10-17 Thread Random832
Brian Gladman writes: >> On Sat, Oct 17, 2015 at 03:26:46AM +1100, Steven D'Aprano wrote: > I hence support your conclusion that the module should offer randbelow > alone. I would oppose offering randomrange (or offering more than one > of them) since this will pretty

Re: [Python-Dev] PEP 506 secrets module

2015-10-17 Thread Steven D'Aprano
On Sat, Oct 17, 2015 at 03:26:46AM +1100, Steven D'Aprano wrote: > On Fri, Oct 16, 2015 at 06:35:14PM +0300, Serhiy Storchaka wrote: > > > I suggest to add only randrange(). randint() is historical artefact, we > > shouldn't repeat this mistake in new module. The secrets module is not > > good

Re: [Python-Dev] PEP 506 secrets module

2015-10-17 Thread Guido van Rossum
On Sat, Oct 17, 2015 at 2:50 AM, Steven D'Aprano wrote: > [...] > So you can see there is nothing even close to consensus as to which API > is best, which is an argument for keeping all three functions. > No, that's not how we do it in Python. :-) > But significanly, only

Re: [Python-Dev] PEP 506 secrets module

2015-10-17 Thread Random832
Guido van Rossum writes: > On Sat, Oct 17, 2015 at 2:50 AM, Steven D'Aprano > wrote: > > [...] > So you can see there is nothing even close to consensus as to > which API > is best, which is an argument for keeping all three functions. > >

[Python-Dev] Conversion of a standard unicode string to a bit string in Python

2015-10-17 Thread Nemo Nautilius
Hi All, I'm currently programming a set of crypto challenges in order to get a deeper understanding of python and crypto. The problem is to break a repeating key xor data (in a file). In order to do that I need a function to calculate the hamming distance between two strings. To find that one

Re: [Python-Dev] Conversion of a standard unicode string to a bit string in Python

2015-10-17 Thread David Mertz
This list is for discussion of development of the Python core language and standard libraries, not for development *using* Python. It sounds like you should probably do your homework problem on your own, actually, but if you seek advice, something like StackOverflow or python-list are likely to

Re: [Python-Dev] PEP 506 secrets module

2015-10-17 Thread Brian Gladman
> On Sat, Oct 17, 2015 at 03:26:46AM +1100, Steven D'Aprano wrote: [snip] > But significanly, only *one* of the commenters has claimed to have > any significant experience in crypto work, and I will quote him: I didn't specifically claim the experience you requested in responding to your post on

Re: [Python-Dev] PEP 506 secrets module

2015-10-17 Thread Tim Peters
[Steven D'Aprano] >> ... >> I think it is fair to say that out of the three functions, there is >> consensus that randbelow has the most useful functionality in a crypto >> context. Otherwise, people seem roughly equally split between the three >> functions. There doesn't seem to be any use-case

[Python-Dev] PEP 506 secrets module

2015-10-17 Thread Brian Gladman
> Guido van Rossum wrote: > I'm fine with dropping the 3rd arg. But I find the argument to > introduce a new spelling for 1-arg randrange() weak. I should stress that my preference for randbelow over randrange was based purely on their proposed functionality and not on their names. I do however

[Python-Dev] type(obj) vs. obj.__class__

2015-10-17 Thread Eric Snow
In a recent tracker issue about OrderedDict [1] we've had some discussion about the use of type(od) as a replacement for od.__class__. It came up because the pure Python implementation of OrderedDict uses self.__class__ in 3 different methods (__repr__, __reduce__, and copy). The patch in that