[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread Ricky Teachey
On Sun, Jul 19, 2020 at 9:53 PM Stephan Hoyer wrote: > On Fri, Jul 17, 2020 at 9:22 PM Ricky Teachey wrote: > >> >>> # The positional arguments aren't part of the KeyObject >> >>> d[a, b:c, d, e=5, f=6] == d.__getitem__((a, b:c, d), KeyObject(e=5, >> f=6)) >> >> This raises a question that needs

[Python-ideas] Re: Pickle security improvements

2020-07-19 Thread Random832
On Sun, Jul 19, 2020, at 12:42, Stephen J. Turnbull wrote: > > Sure - it'd have to be a new opcode at this point, > > Why? The REDUCE opcode invokes load_reduce which ... oh heck, just post it: > > > I just think the wrong decision was made in the first place, > > Which "first place", the earl

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread David Mertz
On Sun, Jul 19, 2020 at 10:27 PM Jonathan Goble wrote: > One use case that comes up in xarray and pandas is support for indicating >> indexing "modes". For example, when indexing with floating point numbers >> it's convenient to be able to opt-in to approximate indexing, e.g., >> something like:

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread Ricky Teachey
On Sun, Jul 19, 2020 at 10:25 PM Jonathan Goble wrote: > On Sun, Jul 19, 2020 at 9:53 PM Stephan Hoyer wrote: > >> On Fri, Jul 17, 2020 at 9:22 PM Ricky Teachey wrote: >> >>> >>> # The positional arguments aren't part of the KeyObject >>> >>> d[a, b:c, d, e=5, f=6] == d.__getitem__((a, b:c, d),

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread Steven D'Aprano
On Sun, Jul 19, 2020 at 10:24:42PM -0400, Jonathan Goble wrote: > IMHO the above example would be better spelled as: > > array.loc.get(longitude, latitude, method='nearest', tolerance=0.001) One of the use-cases for this is for type hints, where you cannot use method calls. So that's right out.

[Python-ideas] Re: isolating user allocations

2020-07-19 Thread Guido van Rossum
What purpose do you have in mind for making this distinction? Even if it could be done easily (which I doubt), why would this be useful? On Sun, Jul 19, 2020 at 19:01 wrote: > Hello, > > The API provided by PEP 445 makes it possible to intercept allocation > requests through hooks, but it seems

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread Jonathan Goble
On Sun, Jul 19, 2020 at 9:53 PM Stephan Hoyer wrote: > On Fri, Jul 17, 2020 at 9:22 PM Ricky Teachey wrote: > >> >>> # The positional arguments aren't part of the KeyObject >> >>> d[a, b:c, d, e=5, f=6] == d.__getitem__((a, b:c, d), KeyObject(e=5, >> f=6)) >> >> This raises a question that needs

[Python-ideas] isolating user allocations

2020-07-19 Thread wenjunhuang
Hello, The API provided by PEP 445 makes it possible to intercept allocation requests through hooks, but it seems that both user allocations and interpreter allocations are sent to the hooks. Here, user allocations refer to those that are triggered explicitly by the code (e.g. memory allocatio

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread Stephan Hoyer
On Fri, Jul 17, 2020 at 9:22 PM Ricky Teachey wrote: > >>> # The positional arguments aren't part of the KeyObject > >>> d[a, b:c, d, e=5, f=6] == d.__getitem__((a, b:c, d), KeyObject(e=5, > f=6)) > > This raises a question that needs to be answered, then: what would be the > utility of mixing to

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread Eric V. Smith
On 7/19/2020 6:49 PM, David Mertz wrote: On Sun, Jul 19, 2020 at 6:35 PM Dominik Vilsmeier mailto:dominik.vilsme...@gmx.de>> wrote: But this looks unnecessarily complicated. Why can't xarray allow the following:     ds["empty"]["lon", 1:5, "lat", 3:] = 10 which looks very clos

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread David Mertz
On Sun, Jul 19, 2020 at 6:35 PM Dominik Vilsmeier wrote: > But this looks unnecessarily complicated. Why can't xarray allow the > following: > > ds["empty"]["lon", 1:5, "lat", 3:] = 10 > > which looks very close to the proposed syntax below. Not that I'm against > the proposal but I think tha

[Python-ideas] Re: PEP 472 -- Support for indexing with keyword arguments

2020-07-19 Thread Dominik Vilsmeier
On 17.07.20 22:11, Todd wrote: On Fri, Jul 17, 2020 at 12:19 PM David Mertz mailto:me...@gnosis.cx>> wrote: Fwiw, I'm probably -0 on the feature itself. Someone suggested it could be useful for xarray, but I'm not sure now what that would look like. If someone had an example, I coul

[Python-ideas] Re: Restricting Python

2020-07-19 Thread Alex Hall
I'm making [a platform for learning Python]( https://github.com/alexmojaki/futurecoder) which needs to allow users to run arbitrary Python code on the server. Each user gets their own process and I use `import resource; resource.setrlimit(resource.RLIMIT_NOFILE, (0, 0))` to prevent opening any file

[Python-ideas] Re: Use lambda in str.replace/re.sub

2020-07-19 Thread David Mertz
We have this in re.sub(). Not sure we need a second way to do it. On Sun, Jul 19, 2020 at 12:57 PM artem6191 wrote: > Example: '1 1 1 1'.replace('1', lambda char, index: str(index)+char) # '01 > 11 21 31' > ___ > Python-ideas mailing list -- python-id

[Python-ideas] Use lambda in str.replace/re.sub

2020-07-19 Thread artem6191
Example: '1 1 1 1'.replace('1', lambda char, index: str(index)+char) # '01 11 21 31' ___ 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-idea

[Python-ideas] Re: Restricting Python

2020-07-19 Thread Michael Smith
Hi, Robert, I learned about an existing RestrictedPython implementation through Zope/Plone. I can see that it differs from your ideas in some ways, but I think at heart it gets to what you're trying to solve for. Have you read about it? https://restrictedpython.readthedocs.io/en/latest/idea.html

[Python-ideas] Re: Restricting Python

2020-07-19 Thread Chris Angelico
On Mon, Jul 20, 2020 at 2:14 AM Robert wrote: > > > Hi, I’ve been lurking for a while. This is my first real post in a long > time. > > > This is a proposal for a system-less python; that is, a version of > python that does not have file or other inappropriate access to the os. > The idea is to p

[Python-ideas] Re: Pickle security improvements

2020-07-19 Thread Stephen J. Turnbull
Random832 writes: > I guess part of where I'm not sure I'm on solid ground is... is the > pure-python version guaranteed to always exist and always be > available under the name _Unpickler, or is that an implementation > detail? I've been assuming that there was no such guarantee and any > ch

[Python-ideas] Restricting Python

2020-07-19 Thread Robert
Hi, I’ve been lurking for a while.  This is my first real post in a long time. This is a proposal for a system-less python; that is, a version of python that does not have file or other inappropriate access to the os.  The idea is to provide a python environment capable of safely running i

[Python-ideas] Re: New clause in FOR and WHILE instead of ELSE

2020-07-19 Thread Олег Комлев
Thank to all disputants. It is possible to borrow the keyword "case" from PEP-622 (when it appears https://www.python.org/dev/peps/pep-0622). Keyword "case" can be written instead of "else/elif". I.e. case COND: ... [case COND: ...] [case COND: ...] All conditions COND must be different. L

[Python-ideas] Re: Thoughts about Fast Python Engine and Python EveryWhere

2020-07-19 Thread Antoine Pitrou
On Sun, 19 Jul 2020 05:01:48 -0400 Wes Turner wrote: > > Can't remember where I thought I read that libuv + CPython asyncio is > actually faster than node + libuv. "faster" is pretty much meaningless without specifics. libuv + asyncio will certainly be fast if you're mostly transferring packets

[Python-ideas] Re: Thoughts about Fast Python Engine and Python EveryWhere

2020-07-19 Thread Wes Turner
On Thu, Jul 16, 2020, 1:33 PM David Mertz wrote: > On Thu, Jul 16, 2020 at 12:59 PM wrote: > >> Recently I have been thinking about why `JavaScript` with it's horrible >> type system and lots of edge cases has supported so many platform and is >> very fast ... >> First answer is simple, because

[Python-ideas] Re: Thoughts about Fast Python Engine and Python EveryWhere

2020-07-19 Thread Marco Sulla
I remember some years ago I compiled Python 3.4 on Kobo, using an ARM virtual machine with qemu. Since the space on Kobo was little, I removed the standard library. But Python did not work. I had to include some stdlib modules too, like encodings/ascii.py, because I was not able to even print an "H