Hi Terry,
Thanks, but I didn't care because my password is not so long.
I just want to illustrate real world bytes xor usage.
BTW, New MySQL auth methods (sha256 and caching_sha2)
use bytes xor too.
For performance point of view, websocket masking is performance
critical. Tornado uses extension
On 6/22/2018 7:08 AM, INADA Naoki wrote:
Bitwise xor is used for "masking" code like these:
https://github.com/PyMySQL/PyMySQL/blob/37eba60439039eff17b32ef1a63b45c25ea28cec/pymysql/connections.py#L139-L146
This points to a function _my_crypt that is O(n*n) because of using
bytes.append. Usin
Bitwise xor is used for "masking" code like these:
https://github.com/PyMySQL/PyMySQL/blob/37eba60439039eff17b32ef1a63b45c25ea28cec/pymysql/connections.py#L139-L146
https://github.com/tornadoweb/tornado/blob/0b2b055061eb4754c80a8d6bc28614b86954e336/tornado/util.py#L470-L471
https://github.com/torn
On Mon, May 21, 2018 at 11:22:17AM -0700, Chris Barker wrote:
> On Sat, May 19, 2018 at 6:52 AM, Steven D'Aprano
> wrote:
>
> > Philosophical arguments about the nature of computer memory aside, byte
> > objects in Python are collections of ints.
> >
>
> not when you start talking about bit-wise
On Sat, May 19, 2018 at 6:52 AM, Steven D'Aprano
wrote:
> Philosophical arguments about the nature of computer memory aside, byte
> objects in Python are collections of ints.
>
not when you start talking about bit-wise operations :-)
If a "byte" in python was an integer, then we'd use b**2 rath
On Fri, May 18, 2018 at 06:25:19PM -0400, Chris Barker - NOAA Federal via
Python-ideas wrote:
> > I suppose you could argue that a "byte" is a patch of
> > storage capable of holding a number from 0 to 255, as opposed to being
> > the number itself, but that's getting rather existential :)
>
> N
On 18/05/2018 07:07, Greg Ewing wrote:
> Steven D'Aprano wrote:
>> But XORing bytes seems perfectly reasonable. Bytes are numbers, even
>> if we display them as ASCII characters.
>
> Yep. Implement it for bytes, then the user can decode/encode
> as appropriate for the application.
>
Personall
On Fri, 18 May 2018 13:49:58 -0300, Facundo Batista wrote:
> Once you think as the whole sequence of bytes as a sequence of bits (eight
times longer, of course), all questions are easly answered, see below...
I had never considered this before, but it seems very interesting.
Essentially that would
On Sat, May 19, 2018 at 8:25 AM, Chris Barker - NOAA Federal
wrote:
>> I suppose you could argue that a "byte" is a patch of
>> storage capable of holding a number from 0 to 255, as opposed to being
>> the number itself, but that's getting rather existential :)
>
> No, I’m making the distinction t
>> actually, bytes are, well, bytes ;-) -- that is, 8 bits.
>
> Grammatically, you appear to be disagreeing with the assertion that
> bytes are numbers. Is that the case?
Um, yes. Though I think for the rest of the conversation, it’s a
distinction that doesn’t matter.
> If you want to be extremel
On Sat, May 19, 2018 at 2:32 AM, Chris Barker via Python-ideas
wrote:
> On Thu, May 17, 2018 at 11:07 PM, Greg Ewing
> wrote:
>>
>> Steven D'Aprano wrote:
>>>
>>> But XORing bytes seems perfectly reasonable. Bytes are numbers, even if
>>> we display them as ASCII characters.
>
>
> actually, bytes
On 5/18/18 12:32 PM, Chris Barker via Python-ideas wrote:
> actually, bytes are, well, bytes ;-) -- that is, 8 bits. But the point
> is that "bitwise" operations make all the sense in the world for
> bytes, but not for unicode text -- did anyone have a use case for
> bitwise operation on unicode st
2018-05-18 13:32 GMT-03:00 Chris Barker via Python-ideas
:
> or would it operate on the whole sequence as a single collection of bits?
Once you think as the whole sequence of bytes as a sequence of bits
(eight times longer, of course), all questions are easly answered, see
below...
> Would it b
On Thu, May 17, 2018 at 11:07 PM, Greg Ewing
wrote:
> Steven D'Aprano wrote:
>
>> But XORing bytes seems perfectly reasonable. Bytes are numbers, even if
>> we display them as ASCII characters.
>
>
actually, bytes are, well, bytes ;-) -- that is, 8 bits. But the point is
that "bitwise" operations
Steven D'Aprano wrote:
But XORing bytes seems perfectly reasonable. Bytes are numbers, even if
we display them as ASCII characters.
Yep. Implement it for bytes, then the user can decode/encode
as appropriate for the application.
--
Greg
___
Python-i
On 5/17/2018 6:53 AM, Ken Hilton wrote:
Hi all,
We all know the bitwise operators: & (and), | (or), ^ (xor), and ~
(not). We know how they work with numbers:
420 ^ 502
110100100
10110
== XOR ==
001010010
= 82
But it might be useful in some cases to (let's say) xor a string (or
bytestri
I agree with Steven. XORing unicode strings doesn't make sense, and is
pointless anyway. The only interesting question is whether we want to
add bytewise operations to the stdlib.
Regards
Antoine.
On Thu, 17 May 2018 23:13:22 +1000
Steven D'Aprano wrote:
> On Thu, May 17, 2018 at 03:49:02PM
On Thu, 17 May 2018 23:13:22 +1000, Steven D'Aprano wrote:
> No, he didn't explain the meaning. He gave an example, but not a reason
why it should do what he showed.
>
> Why should the *abstract character* 'H' XORed with the abstract
character 'w' return the abstract character '?'? Why shouldn't t
Indeed, at this point Numpy sounds like the ideal solution for such use
cases.
Regards
Antoine.
On Thu, 17 May 2018 13:06:59 +0200
Stephan Houben
wrote:
> Seems you want numpy:
>
> >>> import numpy
> >>> numpy.frombuffer(b"Hello", dtype=numpy.uint8) ^
> numpy.frombuffer(b"World", dtype=num
On Thu, May 17, 2018 at 03:49:02PM +0300, Serhiy Storchaka wrote:
> 17.05.18 15:20, Steven D'Aprano пише:
> >On Thu, May 17, 2018 at 02:14:10PM +0300, Serhiy Storchaka wrote:
> >>17.05.18 13:53, Ken Hilton пише:
> >>>But it might be useful in some cases to (let's say) xor a string (or
> >>>bytestri
17.05.18 15:20, Steven D'Aprano пише:
On Thu, May 17, 2018 at 02:14:10PM +0300, Serhiy Storchaka wrote:
17.05.18 13:53, Ken Hilton пише:
But it might be useful in some cases to (let's say) xor a string (or
bytestring):
The question is how common a need of these operations? If it is not
common
On Thu, May 17, 2018 at 02:14:10PM +0300, Serhiy Storchaka wrote:
> 17.05.18 13:53, Ken Hilton пише:
> >We all know the bitwise operators: & (and), | (or), ^ (xor), and ~
> >(not). We know how they work with numbers:
> >
> >420 ^ 502
> >
> >110100100
> >10110
> >== XOR ==
> >001010010
> >= 82
17.05.18 13:53, Ken Hilton пише:
We all know the bitwise operators: & (and), | (or), ^ (xor), and ~
(not). We know how they work with numbers:
420 ^ 502
110100100
10110
== XOR ==
001010010
= 82
But it might be useful in some cases to (let's say) xor a string (or
bytestring):
The questi
Seems you want numpy:
>>> import numpy
>>> numpy.frombuffer(b"Hello", dtype=numpy.uint8) ^
numpy.frombuffer(b"World", dtype=numpy.uint8)
array([31, 10, 30, 0, 11], dtype=uint8)
Stephan
2018-05-17 12:53 GMT+02:00 Ken Hilton :
> Hi all,
>
> We all know the bitwise operators: & (and), | (or), ^ (
Hi all,
We all know the bitwise operators: & (and), | (or), ^ (xor), and ~ (not).
We know how they work with numbers:
420 ^ 502
110100100
10110
== XOR ==
001010010
= 82
But it might be useful in some cases to (let's say) xor a string (or
bytestring):
HELLO ^ world
01001000 01000101 010011
25 matches
Mail list logo