[Python-ideas] Re: Custom string prefixes

2019-08-29 Thread Andrew Barnert via Python-ideas
as a special restricted calling syntax, unless you want to actively impede your understanding of the code. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/ma

[Python-ideas] Re: Custom string prefixes

2019-08-29 Thread Andrew Barnert via Python-ideas
assumption, but instead judge each case on its own merits, you end up with a language which is better than languages at either extreme. There are plenty of cases where Python generalizes beyond most languages (how many languages use the same feature for async functions and sequence iteration? or

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Andrew Barnert via Python-ideas
On Aug 29, 2019, at 05:25, Philippe Prados wrote: > > Hello everybody, > Scala 3 propose the a new syntax for Union type. See here. I propose to add a > similar syntax in Python. > # Operator for Union > assert( int | str == Union[int,str]) > assert( int | str | float =

[Python-ideas] Re: Custom string prefixes

2019-08-29 Thread Andrew Barnert via Python-ideas
’s in a function body, this is effectively the same problem as global or builtin lookups being too slow inside a function body, and can be solved the same way, with a keyword parameter with a default value. And if the Python community thinks that _sin=sin is good enough for the uncommon problem of l

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Andrew Barnert via Python-ideas
sed the first time around. But, balanced against the long-standing Python-specific use of tuples for small numbers of alternatives, including alternative types in places like isinstance, except, etc.? Maybe that beats the cross-linguistic issue. Either one seems a lot better than breaking backward compat

[Python-ideas] Re: Custom string prefixes

2019-08-29 Thread Andrew Barnert via Python-ideas
son. A compiled regex isn’t literally a string, but neither is a bytes; it’s still clearly _similar_ to a string, in important ways. And so is a path, or a URL (although I don’t know what you’d use the url prefix for in Python, given that we don’t have a string-ish type like ObjC’s NSURL to ret

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Andrew Barnert via Python-ideas
On Aug 29, 2019, at 12:54, Chris Angelico wrote: >> Either one seems a lot better than breaking backward compatibility by adding >> new operator methods to the type type. >> > > How does that break backward compat? It doesn’t make Python backward incompatible; it doe

[Python-ideas] Re: Custom string prefixes

2019-08-29 Thread Rob Cliffe via Python-ideas
On 29/08/2019 22:10:21, Andrew Barnert via Python-ideas wrote: As I’ve said before, I believe that anything that doesn’t have a builtin type does not deserve builtin syntax. And I don’t understand why that isn’t a near-ubiquitous viewpoint. +1 (maybe that means I'm missing something).

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Andrew Barnert via Python-ideas
_ror__ wouldn’t handle that, something funky about type, or about builtin types in general, that I’m forgetting? _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Andrew Barnert via Python-ideas
course you could be trying to add type checking to some weird legacy codebase that doesn’t do things Pythonically, so you have to use Union returns. But that’s specific to that one weird codebase. Meanwhile, Optional return values are common all over Python. Also, Python’s typing system is a lot

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Andrew Barnert via Python-ideas
s ? as an id-cont character, with the Schemeish convention, and the ?: operator, and in some other contexts it’s a syntax error but in some it does… whatever that string-or-ord thing is. ___________ Python-ideas mailing list -- python-ideas@python.org

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Andrew Barnert via Python-ideas
On Aug 29, 2019, at 18:10, Guido van Rossum wrote: > >> On Thu, Aug 29, 2019 at 5:56 PM Andrew Barnert via Python-ideas >> wrote: >> I think {int, str}, which someone proposed in one of the earlier >> discussions, is nice. What else would a set of types me

[Python-ideas] Re: Custom string prefixes

2019-08-29 Thread Andrew Barnert via Python-ideas
if nobody else agrees, fine. But if I could __all__ it, I could get what I want anyway. :) ___ 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-i

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Rob Cliffe via Python-ideas
ree. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> _______ Python-ideas mailing list -- python-ideas@pytho

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Andrew Barnert via Python-ideas
complicated change than that. ___ 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/a

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Andrew Barnert via Python-ideas
onvince people they’re better, and then implement them in the subclasscheck method. Changing the signature of isinstance is irrelevant. And that’s all orthogonal to, and almost completely unrelated to, adding |. _______ Python-ideas mailing list -- pytho

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-30 Thread Andrew Barnert via Python-ideas
On Aug 30, 2019, at 18:40, Pasha Stetsenko wrote: >> I can’t think of any uses other than Optional. > > Also, in IPython and Jupyter Lab `?smth` displays help for symbol `smth`. Yeah, and probably more Python users regularly use IPython than, say, BASIC, so maybe a bit more p

[Python-ideas] Re: Adding support for adequately tagging AIX (pep425) to support distributed wheels

2019-09-01 Thread Andrew Barnert via Python-ideas
pecific PyPA lists, or a platform-specific mailing list (I’m not sure if there is one for AIX), and only come to -ideas or -dev if someone thinks it might going to step on unintended toes or can’t be resolved without getting wider input. ___ Python-ideas

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-03 Thread Rob Cliffe via Python-ideas
ot;, and I'm not sure whether that's an argument in favour or against. ChrisA ___ 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/ Me

[Python-ideas] Re: Add a `dig` method to dictionaries supporting the retrieval of nested keys

2019-09-03 Thread James Livermont via Python-ideas
It seems most of the folks on this thread have similar feelings on this, so I will drop this idea. We'll probably standardize on using glom for now. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-

[Python-ideas] Re: Custom string prefixes

2019-09-03 Thread Andrew Barnert via Python-ideas
t for >>> a given network protocol. >>> >> A text string is a sequence of characters. By "byte", I really mean >> "octet", but Python prefers to say "byte". > > And a character is a byte or sequence of bytes. (Odd-sized bytes are pr

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-03 Thread Andrew Barnert via Python-ideas
ion of Python, so you can use it in annotations and still run your code in 3.5 or something (you can’t type-check it as 3.5 code, but that rarely matters). * The same value can be passed to `isinstance` and will work as intended in every version of Python, unlike `Union[int, str]`, which

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-03 Thread Andrew Barnert via Python-ideas
I raised the issue in the first place. Using a `?` suffix isn’t just potentially ugly as in your example, it’s also potentially confusing given languages that use `?=` as null-coalescing assignment or equality, not to mention forever closing off the possibility of adding that feature to Python (

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-03 Thread Andrew Barnert via Python-ideas
On Sep 3, 2019, at 19:45, Steven D'Aprano wrote: > > On Thu, Aug 29, 2019 at 06:20:55PM +0100, Rob Cliffe via Python-ideas wrote: > >>> isinstance(x, str | int) ==> "is x an instance of str or int" >> >> Er, is that necessary when you can alre

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-04 Thread Andrew Barnert via Python-ideas
On Sep 4, 2019, at 01:29, Inada Naoki wrote: > > On Wed, Sep 4, 2019 at 1:15 PM Andrew Barnert via Python-ideas > wrote: >> >> >> But that implies that you can also write this: >> >>isinstance(x, Union[str, int]) >> >> … because, af

[Python-ideas] Re: Add a "block" option to Executor.submit

2019-09-04 Thread Andrew Barnert via Python-ideas
er to block until a worker is free to handle the > request. I believe that this would be trivial to implement by passing the > "block" option through to the Executor's internal Queue.put call > (https://github.com/python/cpython/blob/242c26f53edb965e9808dd918089e664c02

[Python-ideas] Re: Add a "block" option to Executor.submit

2019-09-04 Thread Andrew Barnert via Python-ideas
current39 or whatever backport package on PyPI. (I assume both you and Chris need this feature now (and can’t afford to wait 1.5 years or longer until you can get away with requiring Python 3.9+), and I suspect there are multiple others in the same boat, so it seems like there’s a good chance someon

[Python-ideas] Re: Add a "block" option to Executor.submit

2019-09-04 Thread Andrew Barnert via Python-ideas
On Sep 4, 2019, at 10:17, Anders Hovmöller wrote: > > >> On 4 Sep 2019, at 18:31, Andrew Barnert via Python-ideas >> wrote: >> >> On Sep 4, 2019, at 04:21, Chris Simmons wrote: >> >> I have seen deployed servers that wrap an Executor with a Semapho

[Python-ideas] Re: Add a "block" option to Executor.submit

2019-09-04 Thread Andrew Barnert via Python-ideas
citly queue-based? After all, it’s a bit wasteful—and a bit more complicated—to put a semaphore in front of a bounded queue instead of just using the queue bounds. (And the inefficiency may be even worse in Python, because of its relatively high function call overhead, if using the semaphore requi

[Python-ideas] Re: Add a "block" option to Executor.submit

2019-09-04 Thread Andrew Barnert via Python-ideas
lelizing code that isn’t in a bottleneck, and then adding locks to it, is a pessimization). _______ 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/pytho

[Python-ideas] Re: Add a "block" option to Executor.submit

2019-09-04 Thread Andrew Barnert via Python-ideas
3 line solution. Why would it cause complications? It’s dead simple to design and implement, dead simple to understand, and relies on well-understood and well-rested behavior that’s been part of the queue and mp modules since long before concurrent even existed. ____

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-05 Thread Andrew Barnert via Python-ideas
on where they’re checking types of a zillion objects, they’re definitely not going to guess that it’s 5x as slow, so there definitely going to misuse it. ___________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-i

[Python-ideas] Re: Add a "block" option to Executor.submit

2019-09-05 Thread Andrew Barnert via Python-ideas
away if it turns out to be confusing or buggy or whatever usually means breaking existing code. (Don’t take that past “take that into account and think twice” into “reject all flexibility without a second thought”, or you’ll end up in extreme programming dogma land, and then you’ll be forced

[Python-ideas] Re: Conditional dict declarations

2019-09-05 Thread Andrew Barnert via Python-ideas
that uses d.skip, the one that uses type(d).skip (like a special method lookup), or the one that uses dict.skip? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.pytho

[Python-ideas] Re: Conditional dict declarations

2019-09-05 Thread Andrew Barnert via Python-ideas
> On Sep 5, 2019, at 07:46, Sebastian Kreft wrote: > > How is this different to the discussion > https://mail.python.org/archives/list/python-ideas@python.org/thread/MFSL3U6V74PZN4AT4JFQMQXSMGOJ6F27/#MFSL3U6V74PZN4AT4JFQMQXSMGOJ6F27 > ? Well, that discussion started wit

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-05 Thread Andrew Barnert via Python-ideas
On Sep 5, 2019, at 02:15, Chris Angelico wrote: > > On Thu, Sep 5, 2019 at 7:08 PM Andrew Barnert via Python-ideas > wrote: >> >> On Sep 4, 2019, at 20:51, Inada Naoki wrote: >> >>>> And you’re right, because int|str _looks_ better than (int, str) her

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-05 Thread Andrew Barnert via Python-ideas
at I quoted in snipped text]. > isinstance is a wrapper around PyObject_IsInstance(obj, class_or_tuple), > and if I'm reading the C code correctly, PyObject_IsInstance is roughly > equivalent to this Python pseudo-code: > ># Except in C, not Python >def isinstance(obj

[Python-ideas] Re: [OT] Designing for Concurrency (was: Add a "block" option to Executor.submit)

2019-09-05 Thread Andrew Barnert via Python-ideas
t in practice, I’m pretty sure either that people only need “block”, or that they only need “block” and “raise”. I’m just not sure which of those two.___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org htt

[Python-ideas] Re: [OT] Designing for Concurrency (was: Add a "block" option to Executor.submit)

2019-09-05 Thread Andrew Barnert via Python-ideas
) handles virtually all of the simple cases that I can think of or that anyone else has suggested, and I don’t think it matters much how many of the moderate or extremely complicated cases it handles. ___ Python-ideas mailing list -- python-ideas@python.org

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-05 Thread Andrew Barnert via Python-ideas
Two more bits of bikeshedding… On Sep 5, 2019, at 12:12, Andrew Barnert via Python-ideas wrote: > >> On Sep 5, 2019, at 04:24, Steven D'Aprano wrote: >> >> If Union is a built-in, we could have something like this: >> >> def isinstance(obj, class_or_t

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-06 Thread Andrew Barnert via Python-ideas
handling as >> the second argument of isinstance and issubclass and maybe except >> statements? > Union, and unions, are currently types: > py> isinstance(Union, type) > True >  > py> isinstance(Union[int, str], type) > True What version of Python are you usi

[Python-ideas] Re: Conditional dict declarations

2019-09-06 Thread Andrew Barnert via Python-ideas
. But a magic value that can never be stored in any dict? That sounds nice at first, but I think once you think it through, it would be a nightmare. Especially when you consider how fundamental dicts are to all of Python. Globals is a dict. Locals is a dict in some contexts, not others (and the

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-06 Thread Andrew Barnert via Python-ideas
>> > py> isinstance(Union[int, str], type) >> > True >> >> What version of Python are you using here? > > Ah, I didn't realise that the behaviour has changed! I was using Python > 3.5, but I just tried again in 3.8: I didn't even consider that this mig

[Python-ideas] Re: Conditional dict declarations

2019-09-07 Thread Rob Cliffe via Python-ideas
mes out ragged in your browser, the colons and equal signs are meant to be vertically aligned. Rob Cliffe ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman

[Python-ideas] Support for atomic types in Python

2019-09-08 Thread Vinay Sharma via Python-ideas
Currently, C++ has support for atomic types, on which operations like add, sub, xor, etc can be done atomically, thereby avoiding data races. Having such a support will be very helpful in Python. For instance users won't have to use Locks for synchronising shared variables in ca

[Python-ideas] Re: Conditional dict declarations

2019-09-08 Thread Rob Cliffe via Python-ideas
On 07/09/2019 18:59:49, Chris Angelico wrote: On Sat, Sep 7, 2019 at 11:27 PM Rob Cliffe via Python-ideas wrote: A chance for me to bang the drum on one of my pet themes: Sometimes the readability of code is improved by breaking the sacred taboo of 1 statement per line, if it allows similar

[Python-ideas] Re: Add gamma function to cmath module

2019-09-08 Thread Andrew Barnert via Python-ideas
for extreme values), and doesn’t give the same values for float and complex (e.g., for 1/3, they differ by 6ulp). Is that good enough for the stdlib? _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ide

[Python-ideas] Re: Conditional dict declarations

2019-09-08 Thread Andrew Barnert via Python-ideas
a bunch of separate locals. Well, I suppose you could use locals itself as that namespace: query_data = {k: v for (k, v) in locals().items() if k in {'max_results', 'active', 'deleted'} and v} … but that’s pretty horrible. And I suppose there is something Pyth

[Python-ideas] Re: Add gamma function to cmath module

2019-09-08 Thread Andrew Barnert via Python-ideas
e they”. :) ___ 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@pyth

[Python-ideas] Re: Support for atomic types in Python

2019-09-09 Thread Vinay Sharma via Python-ideas
rget=func, args=(v, lock)) for i in range(10)]    for p in procs: p.start()    for p in procs: p.join()    print(v.value) Because as far as I can perceive none of the types or operations you mention have any race conditions in multi-threaded Python code, and for multi-process or async code that is n

[Python-ideas] Re: Support for atomic types in Python

2019-09-09 Thread Andrew Barnert via Python-ideas
e change, and often even longer to force all of your users/deployments to upgrade.) _______ 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-ide

[Python-ideas] Re: Conditional dict declarations

2019-09-09 Thread Rob Cliffe via Python-ideas
On 08/09/2019 19:34:33, Chris Angelico wrote: On Mon, Sep 9, 2019 at 4:13 AM Rob Cliffe via Python-ideas wrote: On 07/09/2019 18:59:49, Chris Angelico wrote: On Sat, Sep 7, 2019 at 11:27 PM Rob Cliffe via Python-ideas wrote: A chance for me to bang the drum on one of my pet themes

[Python-ideas] Re: Conditional dict declarations

2019-09-09 Thread Andrew Barnert via Python-ideas
for it and writing a for_json or as_dict or whatever, you can just use a SimpleNamespace. ___ 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/pyt

[Python-ideas] Re: PEP-603: Adding a frozenmap type to collections

2019-09-12 Thread Andrew Barnert via Python-ideas
On Sep 12, 2019, at 04:46, Yury Selivanov wrote: > > Hi! > > I've just published a PEP to add a frozenmap type to Python; it should > be online shortly. > > Read it here: > https://discuss.python.org/t/pep-603-adding-a-frozenmap-type-to-collections/2318 How doe

[Python-ideas] Re: PEP-603: Adding a frozenmap type to collections

2019-09-12 Thread Andrew Barnert via Python-ideas
ables uses the same C data structure implementation that’s already in Python surely outweighs the fact that it’s not a category-killer. (i assume that either there’s a pure-Python version for PyPy and other implementations, or that those implementations are expected to already include some code that’s

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Vinay Sharma via Python-ideas
of multiprocessing. > On 10-Sep-2019, at 2:27 PM, Antoine Pitrou wrote: > > > Hi Vinay, > > On Mon, 09 Sep 2019 08:23:48 - > Vinay Sharma via Python-ideas > wrote: >> >> Also, as far as I know (might be wrong) Value is stored in shared memory and >

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Vinay Sharma via Python-ideas
3/09/2019 14:32, Vinay Sharma via Python-ideas wrote: >> As you said there can be lot of possible use cases for the proposed >> feature, since there are lot’s of use cases for a lock. I can tell >> you some cases which I am facing. > > I don't in principle object to having la

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Vinay Sharma via Python-ideas
ould your atomic access work? > > -- > Rhodri James *-* Kynesim Ltd > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/ma

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Vinay Sharma via Python-ideas
If you want atomicity across processes, you > need some kind of lock at some level. > > -- > Rhodri James *-* Kynesim Ltd _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
building and runtime, and writing an autoconf test to boot, is good enough for C++, why does your solution need to be in the stdlib rather than a PyPI library in Python? Meanwhile: > On Sep 13, 2019, at 06:32, Vinay Sharma via Python-ideas > wrote: > > Let’s say I have a parent p

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
On Sep 13, 2019, at 09:31, Vinay Sharma via Python-ideas wrote: > > multiprocessing.Value can be synchronised using a lock, but if I have > multiple multiprocessing.Value(s) which I want to synchronise between two > processes, then I will have to pass a lock for each multiproc

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
e all 12 values or none of them. But that the proposed mp.AtomicValue wouldn’t help there either.___________ 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/pyth

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
On Sep 13, 2019, at 10:42, Antoine Pitrou wrote: > > On Fri, 13 Sep 2019 10:27:10 -0700 > Andrew Barnert via Python-ideas > wrote: >> >> (If you want a shiny modern solution instead, this looks like one of the few >> cases where hardware TM support can proba

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
> On Sep 13, 2019, at 12:21, Richard Musil wrote: > >> On Fri, Sep 13, 2019 at 7:28 PM Andrew Barnert via Python-ideas >> wrote: > >> First, I’m pretty sure that, contrary to your claims, C++ does not support >> this. C++ doesn’t even support shared memor

[Python-ideas] Re: Need a core developer sponsor for a PEP

2019-09-17 Thread Andrew Barnert via Python-ideas
want to create a new builtin type for unions, rather than having a bunch of different parts of the Python core import from typing. * In addition to other benefits, someone (Stephen?) pointed out that builtin support could mean that, e.g., isinstance(3, int|str) could be just as efficient as isi

[Python-ideas] Re: Need a core developer sponsor for a PEP

2019-09-17 Thread Andrew Barnert via Python-ideas
wo-kinded” type system vs. leaning more into “everything is first-class”. _______ 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

[Python-ideas] Re: Need a core developer sponsor for a PEP

2019-09-19 Thread Andrew Barnert via Python-ideas
nd can’t be used in issubclass at all. If you’re changing that some these are now legal calls, you have to decide which ones, and what those calls return. > * You will probably want to create a new builtin type for unions, rather > than having a bunch of different parts of the Python c

[Python-ideas] Re: Set operations with Lists

2019-09-19 Thread Andrew Barnert via Python-ideas
l part). > Even the plain python code is faster than the built in set functions (afaik). You’re testing pretty small values in a very narrow use case, and testing them inaccurately by using datetime instead of timeit (the fact that some of your results are 0 vs. 0 should be a clue…), and

[Python-ideas] Re: Set operations with Lists

2019-09-19 Thread Andrew Barnert via Python-ideas
I added a version of your algorithm that works with arbitrary iterables and also takes a key function (which you always want when you’re doing anything related to sorting in Python), and it’s about 10-20% faster than your list version, which shows that you aren’t getting any performance ben

[Python-ideas] Re: Set operations with Lists

2019-09-19 Thread Andrew Barnert via Python-ideas
n+mlogm+n+m) as you’re proposing. _______ 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.p

[Python-ideas] Re: Set operations with Lists

2019-09-19 Thread Andrew Barnert via Python-ideas
l part). >>> Even the plain python code is faster than the built in set functions >>> (afaik). >> You’re testing pretty small values in a very narrow use case, and testing >> them inaccurately by using datetime instead of timeit (the fact that some of >> your res

[Python-ideas] Re: Set operations with Lists

2019-09-19 Thread Andrew Barnert via Python-ideas
you need. _______ 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.or

[Python-ideas] Re: Set operations with Lists

2019-09-19 Thread Andrew Barnert via Python-ideas
oes not overthrow decades of theoretical proofs and practical experience. Hash tables really do work. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mail

[Python-ideas] Re: Set operations with Lists

2019-09-20 Thread Andrew Barnert via Python-ideas
)` and maybe checking the len to pick which one. If you really want to go overboard with micro-optimizing this version, you might want to also check whether stashing bset.__contains__ and using that speeds things up (which may be different across recent versions of Python with changes to method ca

[Python-ideas] Re: Set operations with Lists

2019-09-20 Thread Andrew Barnert via Python-ideas
r to a hash table, which is an array of buckets in hash order, which isn’t the order you’re going to be accessing them in for the b set. If the values are strings, the pointers point to PyUnicode structs, each of which holds… well, it’s complicated, but in this case (where they’re all pure ASCII a

[Python-ideas] Re: Set operations with Lists

2019-09-20 Thread Andrew Barnert via Python-ideas
of CPUs because they were fooling the computer into thinking they were never going to read past the end of the current page so it didn’t prefetch the next one. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-id

[Python-ideas] Re: Set operations with Lists

2019-09-20 Thread Andrew Barnert via Python-ideas
list, at which point the choice is made for you. So, this already eliminates the possibility of reimplementing set operations with step-compare as suggested earlier. But it also already makes a compelling case for adding step-compare functions to Python—but that case needs to be made clearly. I thi

[Python-ideas] Re: Set operations with Lists

2019-09-20 Thread Andrew Barnert via Python-ideas
> large lists you have to tell them to convert to sets and then back again. > Forget the new programmers who tried the naive way and quite because "python > is too slow", they are waiting 20 seconds when we could deliver it to them > in 1 second. But today, you can d

[Python-ideas] Re: Set operations with Lists

2019-09-22 Thread Andrew Barnert via Python-ideas
d be a huge win over sets. _______ 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

[Python-ideas] Re: Set operations with Lists

2019-09-22 Thread Andrew Barnert via Python-ideas
already in memory, I’ll bet there’s some kind of pandas/HDF way to do it that buffers up large chunks and optimizes the hell out of everything and blows my code away. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email

[Python-ideas] Re: Set operations with Lists

2019-09-22 Thread Andrew Barnert via Python-ideas
mance in some cases, but that’s hard to generalize about. Overall, you probably want them when you need to preserve input order, or use a key function, etc., not when sets aren’t fast enough. _______ Python-ideas mailing list -- python-ideas@python.org To uns

[Python-ideas] Re: Set operations with Lists

2019-09-22 Thread Andrew Barnert via Python-ideas
d it seems like there are useful things you can do with it. Or maybe almost all such things are worth specifializing differently for random-access vs. inherently-logarithmic data structures, or maybe it’s just too hard to come up with a proper useful abstraction? ____

[Python-ideas] Re: Multiple items for each loop in comprehension

2019-09-22 Thread Andrew Barnert via Python-ideas
think most humans don’t internalize the exact rules for when tuples do and don’t require parens, etc. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python

[Python-ideas] Re: Link: Bidirectional Aliasing in Python

2019-09-22 Thread Andrew Barnert via Python-ideas
se, don’t work with locals, or require >< to be handled at compile time. Do you have at least a sketch of how this works? Also, do you have a real-life use case? Usually when you want the equivalent of “variable references” in Python, you just stick the value in a list or an explicit namespa

[Python-ideas] Re: Link: Bidirectional Aliasing in Python

2019-09-22 Thread Andrew Barnert via Python-ideas
On Sep 22, 2019, at 02:08, Nutchanon Ninyawee wrote: > > More in detail on this link > https://dev.to/circleoncircles/python-ideas-link-bidirectional-aliasing-in-python-3f20 After reading the whole thing… In “explicitly not-copy assignment”: assignment in Python never copies. D

[Python-ideas] Re: Link: Bidirectional Aliasing in Python

2019-09-22 Thread Andrew Barnert via Python-ideas
On Sep 22, 2019, at 18:15, Chris Angelico wrote: > > On Mon, Sep 23, 2019 at 10:42 AM Andrew Barnert via Python-ideas > wrote: >> >>> On Sep 22, 2019, at 02:08, Nutchanon Ninyawee wrote: >>> >>> Link is a language feature that allows multiple varia

[Python-ideas] Re: Link: Bidirectional Aliasing in Python

2019-09-22 Thread Andrew Barnert via Python-ideas
Just answering one of them and ignoring the rest doesn’t really help much to clarify the proposal. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3

[Python-ideas] Re: Set operations with Lists

2019-09-23 Thread Andrew Barnert via Python-ideas
from a filesystem that guarantees sorted order and it supports iterdir, iterators should help quite a bit. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mai

[Python-ideas] Re: Add a generic object comparison utility

2019-09-25 Thread Andrew Barnert via Python-ideas
or by iterating, not by an attribute, your algorithm does the wrong thing. Or, if there’s a back link to the parent that is an attribute, again it does the wrong thing. Not to mention that, because Python is ridiculously dynamic, you can have classes where there’s not even a way to get a list of all

[Python-ideas] Re: Error handling toggle / levels

2019-09-26 Thread Andrew Barnert via Python-ideas
sing it (and doing it explicitly as raise e3 rather than just raise) means you get the same effect as with leaving it disabled, but less efficiently and less friendly to debugging? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscr

[Python-ideas] Re: Add a generic object comparison utility

2019-09-26 Thread Andrew Barnert via Python-ideas
ed can be equal: 1 == 1.0 == Fraction(1, 1). ___________ 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/arc

[Python-ideas] Re: Add __slots__ to dataclasses to use less than half as much RAM

2019-09-27 Thread Andrew Barnert via Python-ideas
t for merging it into the stdlib (and leaving it on PyPI as a backport). If it turned out to be tricky to implement without modifying dataclass itself, explaining why could also be a good argument for moving it into the stdlib. ___________ Python-ideas maili

[Python-ideas] Re: Add Subscriptable ABC

2019-09-27 Thread Andrew Barnert via Python-ideas
not be much cost—and may not even be unintentional?). Or I may be missing something that makes (Sequence, Mapping) inappropriate, of course. _______ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ide

[Python-ideas] Re: Add Subscriptable ABC

2019-09-27 Thread Andrew Barnert via Python-ideas
Is there are reason why you're using 'getattr' instead of 'hasattr'? There is a difference here: if some class defines __getitem__ = None, blocks it from looking like a subscriptable type. That idiom is used for other things like __hash__, even if it’s not used 100% consis

[Python-ideas] Re: Add __slots__ to dataclasses to use less than half as much RAM

2019-09-27 Thread Andrew Barnert via Python-ideas
automated tools (or dataclass-like libraries) into thinking you’re declaring slots named _, a, u, t, and o? (I don’t think there’s any danger of confusing human readers, at least.) _______ Python-ideas mailing list -- python-ideas@python.org To unsubscrib

[Python-ideas] Re: Add Subscriptable ABC

2019-09-29 Thread Andrew Barnert via Python-ideas
I can subscript it. What did you expect the answer to be? I think the idea here is that your type follows the “old sequence protocol”, where you can index it with 0, 1, … until you get an IndexError, without having to check __len__ first. Since there are various bits of Python (including the iter

[Python-ideas] Re: Add Subscriptable ABC

2019-09-30 Thread Andrew Barnert via Python-ideas
On Sep 30, 2019, at 02:38, Paul Moore wrote: > > It's (in my view) sad that the simple hasattr test is no longer > sufficient, and in particular that if you want robustness, Python has > changed to the point where a pseudo subclass check is the "right" way > t

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
On Sep 30, 2019, at 23:46, Ben Rudiak-Gould wrote: > > On Mon, Sep 30, 2019 at 10:08 AM Andrew Barnert via Python-ideas > wrote: >> Also, what we’re checking for really is subtyping. > > Is it? Subtyping in type theory satisfies some axioms, one of which is > transitiv

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
times the other. Python gives you a general framework that lets you define both kinds of relationships—and more; e.g., you can handle relationships that aren’t quite structurally (Go-style) checkable, like Sequence, and you can fudge around legacy issues rather than having to get everything per

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
(how they are), but because what the function does, and in particular > that it does two different things (but pretends it is one). Not really. If you want to be a purist, Python doesn’t do subtyping—or, at best, subtyping is defined as “whatever the subclass hooks say”, which is meaningless bec

<    1   2   3   4   5   6   7   8   9   10   >