[Python-ideas] Re: Traits

2020-02-16 Thread Stephen J. Turnbull
Soni, Answering off-list by moderator request. Before I go on to respond to the details, let me start by saying I'm definitely beginning to understand why you like the Rust syntax for traits, and maybe even some feeling for the semantics, although they're not very well documented anywhere I found

[Python-ideas] Re: Traits

2020-02-16 Thread Steven D'Aprano
On Sun, Feb 16, 2020 at 06:08:54PM +0900, Stephen J. Turnbull wrote: > Answering off-list by moderator request. Are you sure about that? :-) -- Steven ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Antoine Pitrou
On Sat, 15 Feb 2020 14:16:39 -0800 Andrew Barnert via Python-ideas wrote: > > On Feb 15, 2020, at 13:36, Jonathan Crall wrote: > > > > Also, there is no duck-typed class that behaves like an executor, but does > > its processing in serial. Often times a develop will want to run a task in > > p

[Python-ideas] Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
This module should contain operations that can be performed on binary numbers. In the below examples a and b are binary numbers. binary.add(a,b) binary.sub(a,b) binary.mul(a,b) binary.div(a,b) binary.ones_complement(a)//returns 1's complement of a. binary.twos_complement(a)//returns 2's co

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Mark Dickinson
ananthakrishnan15.2001@gmail.com wrote: > In the below examples a and b are binary numbers. Please can you clarify what this means, in Python terms? Are you proposing a _new_ Python type that represents a "binary number", or is `binary.add` (for example) intended to work with existing Python typ

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Antoine Rozo
And what do you call "decimal numbers"? Decimal representation of numbers like returned by str(123456)? Le dim. 16 févr. 2020 à 15:00, Mark Dickinson a écrit : > > ananthakrishnan15.2001@gmail.com wrote: > > In the below examples a and b are binary numbers. > > Please can you clarify what this me

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Kyle Stanley
> FWIW, I agree with Andrew here. Being able to swap a > ThreadPoolExecutor or ProcessPoolExecutor with a serial version using > the same API can have benefits in various situations. One is > easier debugging (in case the problem you have to debug isn't a race > condition, of course :-)). Another

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
I'm proposing a module that has functions intended to work with existing python types. Digital electronics is completely based on "binary number system".As python is used in almost all fields,by adding a seperate module for binary containing operations like ones complement and twos complement

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Mark Dickinson
ananthakrishnan15.2001@gmail.com wrote: > I'm proposing a module that has functions intended to work with existing > python > types. Okay, great. *Which* Python types, specifically? `int`? `bytes`? To help us understand, please can you show example inputs to and output from your proposed `binar

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Antoine Pitrou
On Sun, 16 Feb 2020 09:29:36 -0500 Kyle Stanley wrote: > > After Andrew explained his own use case for it with isolating bugs to > ensure that the issue wasn't occurring as a result of parallelism, threads, > processes, etc; I certainly can see how it would be useful. I could also > see a use cas

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
I'll show the example using one's and two's complement. >>binary.ones_complement(1101100001) 0010011110 >>binary.twos_complement(1101100001) 001001 ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
we can use int(eg:110011),using base designator(eg:b,B). ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archive

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
I'll show the example using one's and two's complement. >>binary.ones_complement(110011) 001100 >>binary.twos_complement(110011) 001101 ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-l

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Serhiy Storchaka
16.02.20 17:21, ananthakrishnan15.2...@gmail.com пише: I'll show the example using one's and two's complement. binary.ones_complement(1101100001) 0010011110 binary.twos_complement(1101100001) 001001 What is the type of the result of binary.ones_complement() and binary.

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Paul Moore
On Sun, 16 Feb 2020 at 15:34, wrote: > > I'll show the example using one's and two's complement. > >>binary.ones_complement(110011) > 001100 But these aren't standard Python types - well, technically, 110011 is 1,100,111,111 - 1 billion, 100 million 111 thousand one hundred and eleven

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Mark Dickinson
ananthakrishnan15.2001@gmail.com wrote: > >>> binary.ones_complement(1101100001) > 0010011110 I see. So you want `binary.ones_complement` to accept a nonnegative Python `int` whose decimal expansion consists entirely of ones and zeros, interpret that decimal expansion as though it's a b

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Antoine Rozo
What is 110011 here? A number written in decimal where you want to interpret digits as binary digits? Why don't you use 0b110011 to have a litteral written in binary representation? Le dim. 16 févr. 2020 à 16:32, a écrit : > > I'll show the example using one's and two's complement. > >>bi

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
what about >>binary.ones_complement(0b110011) or should we use something like "bitstring". ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lis

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Paul Moore
On Sun, 16 Feb 2020 at 16:07, wrote: > > what about > >>binary.ones_complement(0b110011) > > or should we use something like "bitstring". https://pypi.org/project/bitstring/ Paul ___ Python-ideas mailing list -- python-ideas@python.org To unsubscri

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
What would you expect ones_complement(1100) to return? (I'm guessing you'd expect a Python int with value 11.) What about ones_complement(1100)? (I'm guessing that you'd also expect a Python int with value 11 here.) What would ones_complement(ones_complement(1100)) be? What would ones_complem

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
I meant we should use base designator(1b110011). ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Mark Dickinson
ananthakrishnan15.2001@gmail.com wrote: > we can use 0b1100 instead of 1100.Then the output of > binary.twos_complement(0b1100) will be 0b0100 That would be printed as `4`. Is that what you want? Supposing we accept that `binary.twos_complement(0b1100) == 0b0100`. What would `binary.twos_complem

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
wea are using 0b1101100002. hence it will give you a syntax error. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ M

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Barry Scott
> On 16 Feb 2020, at 09:38, ananthakrishnan15.2...@gmail.com wrote: > > This module should contain operations that can be performed on binary numbers. > In the below examples a and b are binary numbers. Assuming you mean that a "binary number" is int then python can do what you want I think.

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
binary.twos_complement(0b0011)==1101 binary.twos_complement(0b0011)==1101 ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.py

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Mark Dickinson
ananthakrishnan15.2001@gmail.com wrote: > binary.twos_complement(0b0011)==1101 > binary.twos_complement(0b0011)==1101 How would you make that possible, when `0b0011` and `0b0011` are the exact same integer? ___ Python-ideas mailing list -- p

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
Then can we use a new Python type that represents a "binary number",which accepts number of bits,sign of number. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.or

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
a and b should be integer with base designator "b" (0b110011) .OR there should be a_new_ Python type that represents a "binary number",which accepts number of bits,sign of number. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe s

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Chris Angelico
On Mon, Feb 17, 2020 at 3:40 AM Mark Dickinson wrote: > > ananthakrishnan15.2001@gmail.com wrote: > > binary.twos_complement(0b0011)==1101 > > binary.twos_complement(0b0011)==1101 > > How would you make that possible, when `0b0011` and `0b0011` are the > exact same integer? Easy: you

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthan ananthan
But there is a problem with (0b1101). 5==0b101 -5==-0b101 but we want output -5==1011. so this is not possible by using integers with base designator "0b". ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthan ananthan
But there is a problem with (0b1101). 5==0b101 -5==-0b101 but we want output -5==1011. so this is not possible by using integers with base designator "0b". so we have to use new Python type that represents a "binary number",which accepts number of bits,sign of number. _

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Barry Scott
> On 16 Feb 2020, at 17:49, ananthan ananthan > wrote: > > But there is a problem with (0b1101). > > 5==0b101 > -5==-0b101 > > but we want output -5==1011. > so this is not possible by using integers with base designator "0b". There is no such thing as an 'integers with base designator "

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Andrew Barnert via Python-ideas
> On Feb 16, 2020, at 05:24, ananthakrishnan15.2...@gmail.com wrote: > > This module should contain operations that can be performed on binary > numbers. I think you have two problems here. The first is that you’re confusing integer values with integer literal syntax. It’s not just that `0b10

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Guido van Rossum
I'm happy to defer to Antoine, who is the subject expert here (and Brian Quinlan, the original author). On Sun, Feb 16, 2020 at 6:48 AM Antoine Pitrou wrote: > On Sun, 16 Feb 2020 09:29:36 -0500 > Kyle Stanley wrote: > > > > After Andrew explained his own use case for it with isolating bugs to

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Kyle Stanley
> I don't think we need to be dogmatic here. If someone wants to provide > it on PyPI, then be it. But if they'd rather contribute it to the > stdlib, we should examine the relevant PR at face value. > Asking it to be exercised first on PyPI is worthwhile if the domain > space is complex or ther

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Antoine Pitrou
On Sun, 16 Feb 2020 17:41:36 -0500 Kyle Stanley wrote: > > As a side note, are we still interested in expanding the public API for the > Future class? Particularly for a public means of accessing the state. The > primary motivation for it was this topic, but I could easily the same > issues comin

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Kyle Stanley
> That sounds useful to me indeed. I assume you mean something like a > state() method? We already have Queue.qsize() which works a bit like > this (unlocked and advisory). Yep, a `Future.state()` method is exactly what I had in mind! I hadn't considered that `Queue.qsize()` was analogous, but t

[Python-ideas] Re: Traits

2020-02-16 Thread Stephen J. Turnbull
Steven D'Aprano writes: > On Sun, Feb 16, 2020 at 06:08:54PM +0900, Stephen J. Turnbull wrote: > > Answering off-list by moderator request. > > Are you sure about that? :-) I'm not sure about much of anything these days. I know how to do it, I just didn't. :-( My apologies to all. Steve ___

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Guido van Rossum
Hm, but doesn't the OP's example require *synchronously* reading and writing the state? On Sun, Feb 16, 2020 at 4:47 PM Kyle Stanley wrote: > > That sounds useful to me indeed. I assume you mean something like a > > state() method? We already have Queue.qsize() which works a bit like > > this

[Python-ideas] Re: SerialExecutor for concurrent.futures + Convenience constructor

2020-02-16 Thread Kyle Stanley
> Hm, but doesn't the OP's example require *synchronously* reading and writing the state? Correct. But in the OP's example, they wanted to use their own "FakeCondition" for reading and writing the state, rather than the executor's internal condition (which is bypassed when you directly access or m