[Python-ideas] Keyword 'THIS'

2020-06-15 Thread Stephen J. Turnbull
M Bfmv writes:

 > ```
 > if [i for i in range(10) if i == 11]:
 > print(this)
 > 
 > Evaluate: []
 > ```

This usage of 'this' in that code is called "anaphora".  It's very
useful in natural language and most (all? :-) natural languages have
it, but in a programming language it requires a convention (that must
be learned and remembered by anyone who reads your code, including
last year's lint programs!) and either requires reserving the
conventional identifier (in your case, 'this') or creating ambiguity
when some programmer uses it for something else.  Some programming
languages have it.  Python has preferred to avoid it.

The assignment operator (aka "walrus operator") that others have
pointed out is a good compromise IMO:

if this := [i for i in range(10) if i == 11]:
print(this)

Of course the walrus operator is very new and has the same burden on
human readers and linters, but it's far more flexible and useful than
the implicit use of anaphora.  I think the addition of the walrus
operator means there will be no anaphora in Python ever.

Steve
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/6IXKHIL4G6ALRG7NNIKFNWXL4WGSEQTP/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] the 'z' string escape

2020-06-15 Thread Stephen J. Turnbull
Soni L. writes:

 > so I propose a \z string escape which lets me write the above as shown 
 > below:
 > 
 >      """switches to toml config format. the old 'repos' \z
 >      table is preserved as 'repos_old'"""

We already have that, if you don't care about left-alignment:

>>> """123456789\
... abcdefghi"""
'123456789abcdefghi'
>>> 

So '\z' would only give us removal of indentation whitespace from the
string.  Too much magic, and it has the same problem that trailing '\'
has: most people will have to intentionally look for it to see it
(though it's easier to spot than trailing '\' for me).
That's a -1 for me.

Steve
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/2FTJ2G3PR7KIODJTWL5SUIM3ZFMAXSSE/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: approximate equality operator ("PEP 485 follow-up")

2020-06-15 Thread Stephen J. Turnbull
Paul Sokolovsky writes:

 > I'd encourage everyone who thinks "I need a very special operator
 > just for me",

I don't think anybody who posts here thinks that, though.  They think
"wow, I could really use this, and I bet other people too."
math.isclose probably tempts somebody somewhere in the world about
once a minute.  Of course they often find out differently -- and
mostly when they do, they're OK with that.  (There are also joke or
half-joke proposals, but that's a different thing, and we're all in on
those jokes.)

 > instead think in terms "Python needs ability to define custom
 > operators".

Reading that *literally* (I take it seriously, below): Python has that
ability already.  It's just that the set of operator *symbols* is
fixed (in a given version of Python), and almost exhausted for
numerical types (but see below ;-).  This has an important implication
for readability: the associativity and precedence order of the symbols
is also fixed, and only needs to be learned once.[1]

If you always want isclose behavior for float "equality", you can't
monkey patch (and you don't want to, I think), but you can subclass:

import math

class Real(float):
exact_eq = float.__eq__
def__eq__(self, other):
return math.isclose(self, other)

or

class AltReal(float):
def __matmul__(self, other):# is self at other? close enuff!
return math.isclose(self,other)

Getting serious, as promised: Of course there will be work to do
ensuring that all floats (more likely, all numbers) are converted to
Reals in each entry point of the module, and probably a lot of
duplication where "_private" versions of functions don't do the
conversion, and "public" versions of them do.  That could be avoided
with custom operator symbols in many cases.

But imposing this work is a deliberate choice of the language
designers, for readability reasons, and maybe others.  Perhaps it
should be reconsidered, but I'm quite conservative on this one.

 > Recent example: implementation of "from __future__ import braces":
 > https://github.com/NeKitDS/braces.py .

I strongly recommend the idiom:

import __future__ as __watch_out_for_jokes__

(Recent?  Isn't that more than a decade old?  Hmmm:

>>> from __future__ import braces
  File "", line 1
SyntaxError: not a chance

Different implementation, I guess. :-D :-þ :-D :-þ :-D :-þ :-D)

Steve


Footnotes: 
[1]  This is not always a benefit.  Occasionally there's a
conventional assignment of symbols to operations where the "natural"
behavior of the operations doesn't fit well with the associativity and
precedence of the operators of 3rd grade arithmetic.  But as a rule
it's helpful.
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/BVZNVCAQCLPPSXU7JWQCQJJKEJCFB33F/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Keyword 'THIS'

2020-06-15 Thread Rob Cliffe via Python-ideas

These examples would seem to be tailor-made for the walrus operator:
On 15/06/2020 16:01, M Bfmv wrote:

Hey all. Ever had some list comprehension hell in your code?
Me neither *whistles 418 happly*...

I was thinking about this idea and while `this` keyword is equalevant 
to `self` i have to explain myself.
English is not my main language, sorry for that :' ) Here is my pseudo 
code.


```
if [i for i in range(10) if i == 11]:
    print(this)

Evaluate: []

if (this := [i for i in range(10) if i == 11]):
    print(this)

```

Another one
```
if [i for i in range(10) if i == 5]:
    print(this)

Evaluate: [5]

if (this := [i for i in range(10) if i == 5]):
    print(this)

```
As I try to show above. It would be neat to make a list comprhension 
if statement and use those results in the if condition as the `this` 
parameter

Instead of declaring variables like

```
a = [i for i in range(10) if i == 5]
if a:
    print(a)

Evaluate: [5]
```

I hope I explained my idea well enough and hope to see something like 
this in the future.

If anyone has questions on my interpretation please ask.



___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/PB7AHBHELBLRFVKRRQL4M3SNWB4RXGNW/
Code of Conduct: http://python.org/psf/codeofconduct/


___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/HKRX73KWADMF6BPTV7SR2JTIK6J6K733/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Bringing the print statement back

2020-06-15 Thread Rob Cliffe via Python-ideas



On 12/06/2020 00:17, MRAB wrote:

On 2020-06-11 22:15, Ethan Furman wrote:

On 06/11/2020 01:18 PM, Rob Cliffe via Python-ideas wrote:

If the new super-duper all-singing-and-dancing-and-make-the-tea 
parser can cope with
'print' without parens, it can cope with print followed by nothing. 
Good addition to the proposal, actually. :-)
(Repeated for clarity: I'm in favour of the proposition for 'print' 
only.)


If
  print

prints a blank line, how are you going to access the "print" function 
as an object?



Context: it's in a statement, on its own, just the name "print".
Yes, that's what I meant.  Yes it's backward incompatible, and while one 
sometimes puts an identifier

on a line by itself (I've done it myself) e.g.
        try:
            foo
        except NameError:
            
it must be rare to do that with 'print', especially outside the REPL.




An academic question at this point as Guido has withdrawn the proposal.


He's allowed to change his mind if there's enough support for it.

___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/FIMRTBATHF2C47YF33MLM2STISE7IYPM/

Code of Conduct: http://python.org/psf/codeofconduct/

___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/7PF3YU23ONPBU4VVLONOINK2AKLKSPLM/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread Wes Turner
Here are the conda-forge/python-feedstock CPython patches:
https://github.com/conda-forge/python-feedstock/tree/master/recipe/patches

They're specified in meta.yml:
https://github.com/conda-forge/python-feedstock/blob/master/recipe/meta.yaml

Patches could probably be included e.g. only for a WASM arch target with
jinja2 templating or just preprocessing selectors
-
https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#templating-with-jinja
-
https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#preprocessing-selectors


On Mon, Jun 15, 2020, 9:01 PM Wes Turner  wrote:

> conda-forge builds for ARM64 now ("miniforge"). Maybe someday conda-forge
> will build packages for WASM, too.
>
> The pyiodide work would probably translate well.
>
> There's a version of JupyterLab compiled to WASM w/ all of pyiodide called
> 'Jyve' that runs totally in the browser... Latest Chrome supports the new
> Native File System API "that lets websites gain write access to the native
> file system"
> https://wicg.github.io/native-file-system/
>
> Jyve has a Brython Jupyter kernel; marked as unsafe due to there being no
> good way to sandbox the app JS from the notebook JS, AFAIU.
>
> WASM and MAC labels is still an open security-related question, AFAIU.
>
> PyQuery has a chained API that's familiar to jQuery users.
> The DOM API in Brython could probably be easily ported to CPython (and
> then Jython, IronPython, PyPy, RustPython).
>
> RustPython may already easily compile to WASM without any patches?
> https://github.com/RustPython/RustPython
>
> On Mon, Jun 15, 2020, 7:12 PM Eric V. Smith  wrote:
>
>> On 6/15/2020 5:11 PM, redrad...@gmail.com wrote:
>> > The question is why not to apply all this patches to CPython to be able
>> > to compile CPython on the Web ?
>>
>> Because that will cause an ongoing support burden for an unknown value.
>> What's wrong with keeping the patches separate?
>>
>> Eric
>> ___
>> 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
>> https://mail.python.org/archives/list/python-ideas@python.org/message/ELFNMA2ZJBI4U56ABU3JUJHF4L7E2T5S/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/4OCRVOVPREOZ4UR3YMJQUJK537SEDJRT/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread Wes Turner
conda-forge builds for ARM64 now ("miniforge"). Maybe someday conda-forge
will build packages for WASM, too.

The pyiodide work would probably translate well.

There's a version of JupyterLab compiled to WASM w/ all of pyiodide called
'Jyve' that runs totally in the browser... Latest Chrome supports the new
Native File System API "that lets websites gain write access to the native
file system"
https://wicg.github.io/native-file-system/

Jyve has a Brython Jupyter kernel; marked as unsafe due to there being no
good way to sandbox the app JS from the notebook JS, AFAIU.

WASM and MAC labels is still an open security-related question, AFAIU.

PyQuery has a chained API that's familiar to jQuery users.
The DOM API in Brython could probably be easily ported to CPython (and then
Jython, IronPython, PyPy, RustPython).

RustPython may already easily compile to WASM without any patches?
https://github.com/RustPython/RustPython

On Mon, Jun 15, 2020, 7:12 PM Eric V. Smith  wrote:

> On 6/15/2020 5:11 PM, redrad...@gmail.com wrote:
> > The question is why not to apply all this patches to CPython to be able
> > to compile CPython on the Web ?
>
> Because that will cause an ongoing support burden for an unknown value.
> What's wrong with keeping the patches separate?
>
> Eric
> ___
> 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
> https://mail.python.org/archives/list/python-ideas@python.org/message/ELFNMA2ZJBI4U56ABU3JUJHF4L7E2T5S/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/J7FDQTGB4Q5D3A4VIII5NHSKD2G46WQE/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] the 'z' string escape

2020-06-15 Thread Soni L.
in Lua 5.2+, there's this string escape that allows you to put 
"whitespace" (in particular, including newlines) in a string literal, by 
skipping them entirely. now, unlike lua's long strings, python *does* 
have escapes in long strings. however, sometimes you have help text:


    "switches to toml config format. the old 'repos' " #cont
    "table is preserved as 'repos_old'"

and... well yeah you can see what I did to make it work. if I used a 
long string here, I'd get a newline and a bunch of indentation in the 
middle.


so I propose a \z string escape which lets me write the above as shown 
below:


    """switches to toml config format. the old 'repos' \z
    table is preserved as 'repos_old'"""

(side note to avoid unnecessary comments: this help text refers to 
database tables and migrations. it's not about lua tables.)

___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/UOLOQXYDJA7QCXUDM2YCU5MLARKVPYAS/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: String module name

2020-06-15 Thread Steven D'Aprano
On Tue, Jun 16, 2020 at 12:19:00AM -, redrad...@gmail.com wrote:

> from "https://python.org/some_module.py; import name

The last thing I want to see is modules start importing code from 
arbitrary, untrustworthy websites.

> It will add possibility to run code with complex name of module 

Why is that a good idea? Why can't you just rename your module with a 
legal identifier and put it on the PYTHONPATH?

It isn't enough to propose an idea to have it accepted. You have to 
explain why that idea is a good idea. If you think that it is so obvious 
why it is a good idea that you don't have to explain why, trust me, it's 
not. If it was so obvious, we would have done it by now.


-- 
Steven
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/XBUR7Y65DUMTQ6MKCPPPYRY2ICUAKCU7/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] String module name

2020-06-15 Thread redradist
What if we introduce the string module:

```python
from "https://python.org/some_module.py; import name

...
```

It will add possibility to run code with complex name of module that cannot be 
presented as set of lexical items and also will allow to load the module from 
external location
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/MLP5N3QIP2II6QFHTGOQYMJ5LGDTJBIA/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Keyword 'THIS'

2020-06-15 Thread Steven D'Aprano
On Mon, Jun 15, 2020 at 03:01:55PM +, M Bfmv wrote:
> Hey all. Ever had some list comprehension hell in your code?
> Me neither *whistles 418 happly*...

If you are having list comprehension hell, you are doing too much in 
list comprehensions. They are a hammer. Not everything is a nail.

> I was thinking about this idea and while `this` keyword is equalevant 
> to `self` i have to explain myself.

I use "this" as a variable in some of my code. If you make it a keyword, 
you will break my code.

"self" is not a heyword, it is an ordinary variable.


> English is not my main language, sorry for that :' ) Here is my pseudo code.
> 
> ```
> if [i for i in range(10) if i == 11]:
> print(this)

You don't need a special keyword for that. Just assign it to a variable.

this = [i for i in range(10) if i == 11]
if this:
print(this)


What's wrong with this solution? You mention it at the end of your 
message, as if it was something to be avoided.

Or in 3.8 and after:

if this := [i for i in range(10) if i == 11]:
print(this)




-- 
Steven
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/YX2NNZTDGQ6LJ74VJJVVXZVH6HVRUX5W/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread Eric V. Smith

On 6/15/2020 5:11 PM, redrad...@gmail.com wrote:

The question is why not to apply all this patches to CPython to be able
to compile CPython on the Web ?


Because that will cause an ongoing support burden for an unknown value. 
What's wrong with keeping the patches separate?


Eric
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/ELFNMA2ZJBI4U56ABU3JUJHF4L7E2T5S/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread Dan Sommers



On Monday, June 15, 2020, at 16:03 -0500, redrad...@gmail.com 
wrote:



Thanks, but I know about this implementation ...

But my question is why not to apply all this patches to 
`CPython` ...


And my question is:  are *you* prepared to develop, test, 
maintain, and support this for the next N years, where N is 5 or 
10 or 15 or more?  Or in some way to compensate those people who 
are?  Or at least present some case as to why such an effort is 
its own compensation?

___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/I5ZT2ORZIE4MHXSQVG6DBFLXV6U3WCB3/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: For quicker execution, don't refcount objects that can't be deleted

2020-06-15 Thread Barry Scott


> On 15 Jun 2020, at 20:48, Christopher Barker  wrote:
> 
> On Mon, Jun 15, 2020 at 9:21 AM Barry Scott  > wrote:
> The problem is when you fork a python process.
> 
> Each of the child processes you would hope shared the state of the
> parent that is not being changed. But because of ref counting
> even unchanging objects get modified by a ref count inc/dec cycle
> and then the page that the object is in is copy-on-write'ed.
> 
> End result is that a children share no pages with the parent.
> 
> I'm out of my depth here, but:
> 
> how many immortal objects are there? Quite a few, but they are small, yes? 
> (None, False, True, small integers, ) and the copy-on-write happens at 
> the page scale (~4096k ???). So would having a bunch of small immortal 
> objects that don't get altered really help? Maybe if they were organised to 
> be all together.

The PR that Guido pointed to works by no longer doing INC/DEC on objects after 
a special call that marks all existing objects as immortal.

This has the effect of allowing all the code and data that has been loaded to 
shared pages of memory.
This can be 100s of MiB of ram in the interesting cases.

> 
> It seems this could make a much more substantial difference if the user could 
> mark certain objects immortal. But that would be pretty tricky -- as Python 
> typically has a lot of small objects in containers -- how would you mark them 
> all?


Only if they are on a page of memory that is not shared by objects that does 
not contain object mortal objects.

That was a discussion on moving the ref counts out of the objects and into 
separates pages so that the objects that do not
change are not Copy-On-Write (COW) un-shared. I think that if ref counts 
survive in CPython then this is a very interesting way out of the
COW problem.

Barry

___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/6SVBXWPMDV75VE6K6KUKH4G44XXA2245/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread redradist
The question is why not to apply all this patches to CPython to be able
to compile CPython on the Web ?
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/TBIQNVL5LZ6RC3IXUGYQIQTPWE3XTUJ5/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread Joao S. O. Bueno
Thre are already projects that build Python using Web Assembly -
But as far as I know, these do not have a good
interface with the document DOM.

https://hacks.mozilla.org/2019/04/pyodide-bringing-the-scientific-python-stack-to-the-browser/

Maybe you'd like to take a look at Brython instead -
it is a compliant Python implementatoin that transpiles
Python to javascript on the client side - TL;DR: you get to write

[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread redradist
Thanks, but I know about this implementation ...

But my question is why not to apply all this patches to `CPython` to be able to 
compile `CPython` on the Web ?
https://github.com/iodide-project/pyodide
https://github.com/dgym/cpython-emscripten

Patches to CPython seems pretty straightforward ...
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/GIQ7RREZAAHO2S6XWVEPN6SDIVXP7GMB/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread Matthew Einhorn
On Mon, Jun 15, 2020 at 4:46 PM  wrote:

> Hi all,
>
> I love Python, but as soon as I need to do something in browser I have to
> use ugly JavaScript !!
>
> Is there any future plans support for compiling CPython to WebAssembly
> using Emscripten ?
>

There is already a project working on this:
https://github.com/iodide-project/pyodide. It's in the alpha stage, but it
does mostly work already.
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/BQYSQVI65OAD4HSO52UZ7TWC7FJVSMT2/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Python WebAssembly Support

2020-06-15 Thread redradist
Hi all,

I love Python, but as soon as I need to do something in browser I have to use 
ugly JavaScript !!

Is there any future plans support for compiling CPython to WebAssembly using 
Emscripten ?
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/XV7U4OHKLRJ5TC3LZUBKAHVKSWTDZOTV/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: For quicker execution, don't refcount objects that can't be deleted

2020-06-15 Thread Christopher Barker
On Mon, Jun 15, 2020 at 9:21 AM Barry Scott  wrote:

> The problem is when you fork a python process.
>
> Each of the child processes you would hope shared the state of the
> parent that is not being changed. But because of ref counting
> even unchanging objects get modified by a ref count inc/dec cycle
> and then the page that the object is in is copy-on-write'ed.
>
> End result is that a children share no pages with the parent.
>

I'm out of my depth here, but:

how many immortal objects are there? Quite a few, but they are small, yes?
(None, False, True, small integers, ) and the copy-on-write happens at
the page scale (~4096k ???). So would having a bunch of small immortal
objects that don't get altered really help? Maybe if they were organised to
be all together.

It seems this could make a much more substantial difference if the user
could mark certain objects immortal. But that would be pretty tricky -- as
Python typically has a lot of small objects in containers -- how would you
mark them all?

-CHB

-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/OIYVVHWHK64PJYRP3SQTGLRAYROD2BLK/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: For quicker execution, don't refcount objects that can't be deleted

2020-06-15 Thread Barry Scott



> On 14 Jun 2020, at 22:59, Ben Rudiak-Gould  wrote:
> 
> There isn't really any contention for these memory locations in
> CPython as it stands because only one interpreter thread can run at a
> time. The only time a cache handoff is needed is during a thread
> switch when the new thread is scheduled on a different core, which is
> pretty rare (at CPU timescales). Adding checks to every incref/decref
> would probably cost more time than it would save.

The problem is when you fork a python process.

Each of the child processes you would hope shared the state of the
parent that is not being changed. But because of ref counting
even unchanging objects get modified by a ref count inc/dec cycle
and then the page that the object is in is copy-on-write'ed.

End result is that a children share no pages with the parent.

Barry
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/4JWUL6GJUWPQBKBKSG3H5IKEZJV45HY7/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Keyword 'THIS'

2020-06-15 Thread Henk-Jaap Wagenaar
*available since Python 3.8. Link here:

https://docs.python.org/3/whatsnew/3.8.html

On Mon, 15 Jun 2020 at 16:06, Henk-Jaap Wagenaar 
wrote:

> How about using the Walrus operator/assignment expression, since Python
> 3.8?
>
> if this := [i for i in range(10) if i == 5]:
>   print(this)
>
> Evaluate: [5]
>
> On Mon, 15 Jun 2020 at 16:03, M Bfmv  wrote:
>
>> Hey all. Ever had some list comprehension hell in your code?
>> Me neither *whistles 418 happly*...
>>
>> I was thinking about this idea and while `this` keyword is equalevant to
>> `self` i have to explain myself.
>> English is not my main language, sorry for that :' ) Here is my pseudo
>> code.
>>
>> ```
>> if [i for i in range(10) if i == 11]:
>> print(this)
>>
>> Evaluate: []
>> ```
>>
>> Another one
>> ```
>> if [i for i in range(10) if i == 5]:
>> print(this)
>>
>> Evaluate: [5]
>> ```
>> As I try to show above. It would be neat to make a list comprhension if
>> statement and use those results in the if condition as the `this` parameter
>> Instead of declaring variables like
>>
>> ```
>> a = [i for i in range(10) if i == 5]
>> if a:
>> print(a)
>>
>> Evaluate: [5]
>> ```
>>
>> I hope I explained my idea well enough and hope to see something like
>> this in the future.
>> If anyone has questions on my interpretation please ask.
>>
>>
>> ___
>> 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
>> https://mail.python.org/archives/list/python-ideas@python.org/message/PB7AHBHELBLRFVKRRQL4M3SNWB4RXGNW/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/JCKQM3XJZIO5EWV3GMAWM3QDCPTVVMGN/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Keyword 'THIS'

2020-06-15 Thread Henk-Jaap Wagenaar
How about using the Walrus operator/assignment expression, since Python 3.8?

if this := [i for i in range(10) if i == 5]:
  print(this)

Evaluate: [5]

On Mon, 15 Jun 2020 at 16:03, M Bfmv  wrote:

> Hey all. Ever had some list comprehension hell in your code?
> Me neither *whistles 418 happly*...
>
> I was thinking about this idea and while `this` keyword is equalevant to
> `self` i have to explain myself.
> English is not my main language, sorry for that :' ) Here is my pseudo
> code.
>
> ```
> if [i for i in range(10) if i == 11]:
> print(this)
>
> Evaluate: []
> ```
>
> Another one
> ```
> if [i for i in range(10) if i == 5]:
> print(this)
>
> Evaluate: [5]
> ```
> As I try to show above. It would be neat to make a list comprhension if
> statement and use those results in the if condition as the `this` parameter
> Instead of declaring variables like
>
> ```
> a = [i for i in range(10) if i == 5]
> if a:
> print(a)
>
> Evaluate: [5]
> ```
>
> I hope I explained my idea well enough and hope to see something like this
> in the future.
> If anyone has questions on my interpretation please ask.
>
>
> ___
> 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
> https://mail.python.org/archives/list/python-ideas@python.org/message/PB7AHBHELBLRFVKRRQL4M3SNWB4RXGNW/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/XTXYE2Y6ZMUVRXJL4RQVZEYFAMRBTDBQ/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Keyword 'THIS'

2020-06-15 Thread M Bfmv
Hey all. Ever had some list comprehension hell in your code?
Me neither *whistles 418 happly*...

I was thinking about this idea and while `this` keyword is equalevant to `self` 
i have to explain myself.
English is not my main language, sorry for that :' ) Here is my pseudo code.

```
if [i for i in range(10) if i == 11]:
print(this)

Evaluate: []
```

Another one
```
if [i for i in range(10) if i == 5]:
print(this)

Evaluate: [5]
```
As I try to show above. It would be neat to make a list comprhension if 
statement and use those results in the if condition as the `this` parameter
Instead of declaring variables like

```
a = [i for i in range(10) if i == 5]
if a:
print(a)

Evaluate: [5]
```

I hope I explained my idea well enough and hope to see something like this in 
the future.
If anyone has questions on my interpretation please ask.


___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/PB7AHBHELBLRFVKRRQL4M3SNWB4RXGNW/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: For quicker execution, don't refcount objects that can't be deleted

2020-06-15 Thread Steve Barnes


-Original Message-
From: Greg Ewing  
Sent: 15 June 2020 07:23
To: python-ideas@python.org
Subject: [Python-ideas] Re: For quicker execution, don't refcount objects that 
can't be deleted

On 15/06/20 5:11 pm, Steve Barnes wrote:

> Of course if we had a NaN value for integers, int('NaN'), then we could just 
> set the initial count to it and since NaN - anything = NaN all would be 
> golden.

Or we could use floating-point reference counts...

--
Greg
[Steve Barnes] 
I thought of floating-point reference counts but:

 a) 65535.0 -= 1 is slower than 65535 =- 1 (7.6% on my system quite a bit worse 
on some embedded systems).
 b) There comes a point in floats, (for large values of x), where x - 1 == x 
(about 10**15 which for some scientific & big data calculations is not that 
big) but unless reference counting uses python integers, rather than C, this 
will not be an issue.
 c) of course I like the concept of integer nan, inf, etc. 


___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/JGU6SHN56CUFKD4QGLDCORNW5BEPGKGD/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: For quicker execution, don't refcount objects that can't be deleted

2020-06-15 Thread Steven D'Aprano
On Mon, Jun 15, 2020 at 06:22:34PM +1200, Greg Ewing wrote:
> On 15/06/20 5:11 pm, Steve Barnes wrote:
> 
> >Of course if we had a NaN value for integers, int('NaN'), then we could 
> >just set the initial count to it and since NaN - anything = NaN all would 
> >be golden.
> 
> Or we could use floating-point reference counts...

Remind me again, was the aim to speed up the interpreter or slow it 
down? 

:-)


-- 
Steven
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/HDOKQ5OPKPX7OSMDVJRZCAU3GCR5UT5M/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: For quicker execution, don't refcount objects that can't be deleted

2020-06-15 Thread Greg Ewing

On 15/06/20 5:11 pm, Steve Barnes wrote:


Of course if we had a NaN value for integers, int('NaN'), then we could just 
set the initial count to it and since NaN - anything = NaN all would be golden.


Or we could use floating-point reference counts...

--
Greg
___
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/5L3A7ZWYSFCKVFSUFOSO47AWJ56DDJBG/
Code of Conduct: http://python.org/psf/codeofconduct/