Re: [Python-Dev] BDFL ruling request: should we block forever waiting for high-quality random bits?

2016-06-11 Thread Tim Peters
[Sebastian Krause] > ... > Ideally I would only want to use the random module for > non-secure and (in 3.6) the secrets module (which could block) for > secure random data and never bother with os.urandom (and knowing how > it behaves). But then those modules should probably get new > functions to

Re: [Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-11 Thread Tim Peters
[redirected from python-dev, to python-ideas; please send followups only to python-ideas] [Elliot Gorokhovsky ] > ... > TL;DR: Should I spend time making list.sort() detect if it is sorting > lexicographically and, if so, use a much faster algorithm? It will be fun to find out ;-) As Mark, and

Re: [Python-Dev] Python 3.6 dict becomes compact and gets a private version; and keywords become ordered

2016-09-12 Thread Tim Peters
[Guido] > Wouldn't attempting to reuse DUMMY entries be expensive? You'd have to > search forward in the array. Just keeping a count of DUMMY entries and > compacting when there are too many seems better somehow. I haven't looked at the code, but presumably one of the members of a DUMMY key/value

Re: [Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-13 Thread Tim Peters
[Terry Reedy ] >> Tim Peters investigated and empirically determined that an >> O(n*n) binary insort, as he optimized it on real machines, is faster >> than O(n*logn) sorting for up to around 64 items. [Nikolaus Rath ] > Out of curiosity: is this test repeated peri

Re: [Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-10 Thread Tim Peters
[please restrict follow-ups to python-ideas] Let's not get hung up on meta-discussion here - I always thought "massive clusterf**k" was a precise technical term anyway ;-) While timing certainly needs to be done more carefully, it's obvious to me that this approach _should_ pay off significantly

Re: [Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-11 Thread Tim Peters
[Terry Reedy] > > This seems like a generic issue with timing mutation methods > ... > But I am sure Tim worked this out in his test code, which should be > reused, perhaps updated with Viktor's perf module to get the most > stable timings possible. sortperf.py is older than me ;-) It's not at al

Re: [Python-Dev] The untuned tunable parameter ARENA_SIZE

2017-06-02 Thread Tim Peters
[INADA Naoki ] > ... > Since current pool size is 4KB and there is pool_header in pool, > we can't allocate 4KB block from pool. > And if support 1KB block, only 3KB of 4KB can be actually used. > I think 512 bytes / 4KB (1/8) is good ratio. > > Do you mean increase pool size? > > How about adding

Re: [Python-Dev] The untuned tunable parameter ARENA_SIZE

2017-06-02 Thread Tim Peters
[Tim] >> While I would like to increase the pool size, it's fraught with >> danger. [Antoine Pitrou ] > What would be the point of increasing the pool size? Apart from being > able to allocate 4KB objects out of it, I mean. > > Since 4KB+ objects are relatively uncommon (I mean we don't allocate

Re: [Python-Dev] The untuned tunable parameter ARENA_SIZE

2017-06-03 Thread Tim Peters
For fun, let's multiply everything by 256: - A "pool" becomes 1 MB. - An "arena" becomes 64 MB. As briefly suggested before, then for any given size class a pool could pass out hundreds of times more objects before needing to fall back on the slower code creating new pools or new arenas. As an a

Re: [Python-Dev] The untuned tunable parameter ARENA_SIZE

2017-06-04 Thread Tim Peters
[Tim] >> A virtual address space span of a terabyte could hold 1M pools, so >> would "only" need a 1M/8 = 128KB bit vector. That's minor compared to >> a terabyte (one bit per megabyte). [Antoine] > The virtual address space currently supported by x86-64 is 48 bits > wide (spanning an address spa

Re: [Python-Dev] The untuned tunable parameter ARENA_SIZE

2017-06-04 Thread Tim Peters
[Tim] >> ... That is, it's up to the bit vector implementation >> to intelligently represent what's almost always going to be a >> relatively tiny slice of a theoretically massive address space. [Antoine] > True. That works if the operating system doesn't go too wild in > address space randomizat

Re: [Python-Dev] The untuned tunable parameter ARENA_SIZE

2017-06-04 Thread Tim Peters
[Larry Hastings ] > ... > Yet CPython's memory consumption continues to grow. By the time a current > "trunk" build of CPython reaches the REPL prompt it's already allocated 16 > arenas. I'd be surprised if that's true ;-) The first time `new_arena()` is called, it allocates space for a vector o

Re: [Python-Dev] The untuned tunable parameter ARENA_SIZE

2017-06-05 Thread Tim Peters
[Larry] > ... > Oh! I thought it also allocated the arenas themselves, in a loop. I > thought I saw that somewhere. Happy to be proved wrong... There is a loop in `new_arena()`, but it doesn't do what a casual glance may assume it's doing ;-) It's actually looping over the newly-allocated teen

Re: [Python-Dev] deque implementation question

2017-07-16 Thread Tim Peters
[Max Moroz ] > What would be the disadvantage of implementing collections.deque as a > circular array (rather than a doubly linked list of blocks)? ... You answered it yourself ;-) > ... > Of course when the circular array is full, it will need to be reallocated, > but the amortized cost of that

Re: [Python-Dev] Impact of Namedtuple on startup time

2017-07-17 Thread Tim Peters
[Giampaolo Rodola' ] > > To be entirely honest, I'm not even sure why they need to be forcefully > declared upfront in the first place, instead of just having a first-class > function (builtin?) written in C: > > >>> ntuple(x=1, y=0) > (x=1, y=0) > > ...or even a literal as in: > > >>> (x=1, y

[Python-Dev] Re: Packing a long list of numbers into memory

2021-10-20 Thread Tim Peters
Sorry for the spam! A bunch of these were backed up in the moderation queue. I used the UI to set the list to auto-discard future messages from this address, but then clicked "Accept" in the mistaken sense of "yes, accept my request to auto-nuke this clown". But it took "Accept" to mean "sure thing

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Tim Peters
[Raymond Bisdorff ] > ... > Please notice the following inconsistency in Python3.10.0 and before of > a sort(reverse=True) result: > > >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')] > >>> L.sort(reverse=True) > >>> L > >>> [(3, 'e'), (2, 'd'), (2, 'b'), (1, 'c'), (1, 'a')] Looks go

[Python-Dev] Re: The list.sort(reverse=True) method not consistent with description

2021-10-30 Thread Tim Peters
[Raymond Bisdorff ] > I fully agree with your point. By default, all the components of the > tuple should be used in the comparison. > > Yet, I was confused by the following result. > >>> from operator import itemgetter > >>> L = [(1, 'a'), (2, 'b'), (1, 'c'), (2, 'd'), (3, 'e')] > >>> L.sort(ke

[Python-Dev] Re: containment and the empty container

2021-11-08 Thread Tim Peters
[Ethan Furman ] > When is an empty container contained by a non-empty container? That depends on how the non-empty container's type defines __contains__. The "stringish" types (str, byte, bytearray) work _very_ differently from others (list, set, tuple) in this respect. t in x for the latter

[Python-Dev] Re: Having Sorted Containers in stdlib?

2021-11-10 Thread Tim Peters
[Christopher Barker ] > Maybe a stupid question: > > What are use cases for sorted dicts? > > I don’t think I’ve ever needed one. For example, for some mappings with totally ordered keys, it can be useful to ask for the value associated with a key that's not actually there, because "close to the k

[Python-Dev] Re: Having Sorted Containers in stdlib?

2021-11-10 Thread Tim Peters
[Bob Fang ] > This is a modest proposal to consider having sorted containers > (http://www.grantjenks.com/docs/sortedcontainers/) in standard library. +1 from me, but if and only if Grant Jenks (its author) wants that too. It's first-rate code in all respects, including that it's a fine example _

[Python-Dev] Re: Having Sorted Containers in stdlib?

2021-11-11 Thread Tim Peters
[Christopher Barker ] > Earlier in the thread, we were pointed to multiple implementations. > > Is this particular one clearly the “best”[*]? > > If so, then sure. > > -CHB > > [*] best meaning “most appropriate for the stdlib”. A couple folks have > already pointed to the quality of the code. But

[Python-Dev] Re: Having Sorted Containers in stdlib?

2021-11-13 Thread Tim Peters
I started writing up a SortedDict use case I have, but it's very elaborate and I expect it would just end with endless pointless argument about other approaches I _could_ take. But I already know all those ;-) So let's look at something conceptually "dead easy" instead: priority queues. They're a

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2021-12-30 Thread Tim Peters
[Gregory P. Smith ] > The reason for digits being a multiple of 5 bits should be revisited vs > its original intent I added that. The only intent was to make it easier to implement bigint exponentiation easily while viewing the exponent as being in base 32 (so as to chew up 5 bits at a time).. Sin

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2021-12-30 Thread Tim Peters
>> The reason for digits being a multiple of 5 bits should be revisited vs >> its original intent > I added that. The only intent was to make it easier to implement > bigint exponentiation easily ... That said, I see the comments in longintrepr.h note a stronger constraint: """ the marshal code

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-14 Thread Tim Peters
]Mark Dickinson ] >> Division may still be problematic. Heh. I'm half convinced that heavy duty bigint packages are so often written in assembler because their authors are driven insane by trying to trick C compilers into generating "the obvious" machine instructions needed. An alternative to HW

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-15 Thread Tim Peters
[Gregory P. Smith ] > ... > That only appears true in default boring -O2 builds. Use > `./configure --enable-optimizations` and the C version is *much* faster > than your asm one... > > 250ns for C vs 370ns for your asm divl one using old gcc 9.3 on my > zen3 when compiled using --enable-optimizat

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Tim Peters
[Tim, incidentally notes that passing 10 as the divisor to inplace_divrem1() is "impossibly fast" on Windows, consuming less than a third the time as when passing seemingly any other divisor] [Mark Dickinson, discovers much the same is true under other, but not all, Linux-y builds, due to the g

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Tim Peters
[Guido] > I don't think there's a way to do a PGO build from Visual Studio; but > a command prompt in the repo can do it using `PCbuild\build.bat --pgo`. > Just be patient with it. Thanks! That worked, and was easy, and gave me an executable that runs "// 10" at supernatural speed. Alas, Visual S

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-17 Thread Tim Peters
[Barry Scott and Steve Dower share tips for convincing Visual Studio to show assembler without recompiling the file] Thanks, fellows! That mostly ;-) workedl. Problem remaining is that breakpoints just didn't work. They showed up "visually", and in the table of set breakpoints, but code went whiz

[Python-Dev] Re: Can I ask a real dumb procedural question about GitHub email?

2022-05-04 Thread Tim Peters
[Skip Montanaro ] > I subscribe to the python/cpython stuff on GitHub. I find it basically > impossible to follow because of the volume. > ... > How (if at all) do people deal with this firehose of email? Am I the > only person dumb enough to have tried? My observation is that, over time, all sour

[Python-Dev] Re: Python Software Foundation Board of Directors Election 2022

2022-06-19 Thread Tim Peters
Heads up! I found my PSF Board voting info in my gmail spam folder today; looks like it was mailed out this morning. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/m

[Python-Dev] Re: PEP 572 TargetScopeError

2019-08-08 Thread Tim Peters
[Barry Warsaw ] > bpo-37757: https://bugs.python.org/issue37757 Really couldn't care less whether it's TargetScopeError or SyntaxError, but don't understand the only rationale given here for preferring the latter: > To me, “TargetScopeError” is pretty obscure and doesn’t give users an > obvious c

[Python-Dev] Re: PEP 572 TargetScopeError

2019-08-09 Thread Tim Peters
[Guido] > I don't see how this debate can avoid a vote in the Steering Council. FWIW, I found Nick's last post wholly persuasive: back off to SyntaxError for now, and think about adding a more specific exception later for _all_ cases (not just walrus) in which a scope conflict isn't allowed (e.g.

[Python-Dev] Re: Spammy stuff (was Re: congrats on 3.5! Alas, windows 7 users are having problems installing it)

2019-09-15 Thread Tim Peters
[This is about the mailing list, not about Python development] That python-dev-owner has gotten two complaints about this message so far suggests I should explain what's going on ;-) New list members are automatically moderated. Their posts sit in a moderation queue waiting for moderator action.

[Python-Dev] Re: Spammy stuff (was Re: congrats on 3.5! Alas, windows 7 users are having problems installing it)

2019-09-15 Thread Tim Peters
[Tim] > While python-dev has several "official" moderators, best I can tell > I'm the only one who has reviewed these messages for years. I should clarify that! That's not meant to be a dig at the other moderators. I review everything because I'm retired and am near the computer many hours almos

[Python-Dev] Re: Compacting the Uncompactable

2019-09-28 Thread Tim Peters
Short course: a replacement for malloc for use in contexts that can't "move memory" after an address is passed out, but want/need the benefits of compactification anyway. Key idea: if the allocator dedicates each OS page to requests of a specific class, then consider two pages devoted to the sam

[Python-Dev] Re: Macros instead of inline functions?

2019-12-04 Thread Tim Peters
[Skip Montanaro ] > ... > I don't think stable code which uses macros should be changed (though > I see the INCREF/DECREF macros just call private inline functions, so > some conversion has clearly been done). Still, in new code, shouldn't > the use of macros for more than trivial use cases (consta

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-15 Thread Tim Peters
[Larry Hastings ] > As of 3.7, dict objects are guaranteed to maintain insertion order. But set > objects make no such guarantee, and AFAIK in practice they don't maintain > insertion order either. If they ever appear to, it's an accident you shouldn't rely on. > Should they? >From Raymond, 22

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-16 Thread Tim Peters
[Guido] > ... > the language should not disappoint them, optimization opportunities be damned. I would like to distinguish between two kinds of "optimization opportunities": theoretical ones that may or may not be exploited some day, and those that CPython has _already_ exploited. That is, we do

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-16 Thread Tim Peters
[Tim] > BTW, what should > > {1, 2} | {3, 4, 5, 6, 7} > > return as ordered sets? Beats me.; [Larry] > The obvious answer is {1, 2, 3, 4, 5, 6, 7}. Why? An obvious implementation that doesn't ignore performance entirely is: def union(smaller, larger): if len(larger) < len(small

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-16 Thread Tim Peters
[Raymond] > ... > * The ordering we have for dicts uses a hash table that indexes into a > sequence. > That works reasonably well for typical dict operations but is unsuitable for > set > operations where some common use cases make interspersed additions > and deletions (that is why the LRU cache

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-16 Thread Tim Peters
[Petr Viktorin ] > ... > Originally, making dicts ordered was all about performance (or rather > memory efficiency, which falls in the same bucket.) It wasn't added > because it's better semantics-wise. As I tried to flesh out a bit in a recent message, the original "compact dict" idea got all the

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-16 Thread Tim Peters
[Tim] >> If it's desired that "insertion order" be consistent across runs, >> platforms, and releases, then what "insertion order" _means_ needs to >> be rigorously defined & specified for all set operations. This was >> comparatively trivial for dicts, because there are, e.g., no >> commutative b

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-16 Thread Tim Peters
[Larry] > Didn't some paths also get slightly slower as a result of maintaining > insertion order when mixing insertions and deletions? I paid no attention at the time. But in going from "compact dict" to "ordered dict", deletion all by itself got marginally cheaper. The downside was the nee

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-17 Thread Tim Peters
... [Larry] >> One prominent Python core developer** wanted this feature for years, and I >> recall >> them saying something like: >> >> Guido says, "When a programmer iterates over a dictionary and they see the >> keys >> shift around when the dictionary changes, they learn something!" To that

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-17 Thread Tim Peters
[Larry] > "I don't care about performance" is not because I'm aching for Python to > run my code slowly. It's because I'm 100% confident that the Python > community will lovingly optimize the implementation. I'm not ;-) > So when I have my language designer hat on, I really don't concern myself

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Tim Peters
[Nick Coghlan ] > Starting with "collections.OrderedSet" seems like a reasonable idea, > though - that way "like a built-in set, but insertion order preserving" will > have an obvious and readily available answer, and it should also > make performance comparisons easier. Ya, I suggested starting w

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Tim Peters
[Nick] > I took Larry's request a slightly different way: Sorry, I was unclear: by "use case" I had in mind what appeared to me to be the overwhelming thrust of the _entirety_ of this thread so far, not Larry's original request. > he has a use case where he wants order preservation (so built in

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Tim Peters
[David Mertz ] > It's not obvious to me that insertion order is even the most obvious or > most commonly relevant sort order. I'm sure it is for Larry's program, but > often a work queue might want some other order. Very often queues > might instead, for example, have a priority number assigned t

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-19 Thread Tim Peters
[Nick] > I must admit that I was assuming without stating that a full OrderedSet > implementation would support the MutableSequence interface. Efficient access via index position too would be an enormous new requirement, My bet: basic operations would need to change from O(1) to O(log(N)). BTW,

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-20 Thread Tim Peters
[Wes Turner ] >> How slow and space-inefficient would it be to just implement the set methods >> on top of dict? [Inada Naoki ] > Speed: Dict doesn't cache the position of the first item. Calling > next(iter(D)) repeatedly is O(N) in worst case. > ... See also Raymond's (only) message in this t

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-20 Thread Tim Peters
[Inada Naoki ] > I just meant the performance of the next(iter(D)) is the most critical part > when you implement orderdset on top of the current dict and use it as a queue. Which is a good point. I added a lot more, though, because Wes didn't even mention queues in his question: [Wes Turner ]

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-23 Thread Tim Peters
;d much rather have a dedicated >>> data structure that clearly describes what it does based on the name alone, >>> IMO that's a million times better for readability purposes. >>> >>> Also, this is mostly speculation since I haven't ran any benchma

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-23 Thread Tim Peters
Sorry! A previous attempt to reply got sent before I typed anything :-( Very briefly: > >>> timeit.timeit("set(i for i in range(1000))", number=100_000) [and other examples using a range of integers] The collision resolution strategy for sets evolved to be fancier than for dicts, to reduce cac

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-23 Thread Tim Peters
[Kyle] > ... > For some reason, I had assumed in the back of my head (without > giving it much thought) that the average collision rate would be the > same for set items and dict keys. Thanks for the useful information. I know the theoretical number of probes for dicts, but not for sets anymore.

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-23 Thread Tim Peters
>> Also, I believe that max "reasonable" integer range of no collision >> is (-2305843009213693951, 2305843009213693951), ... > Any range that does _not_ contain both -2 and -1 (-1 is an annoying > special case, with hash(-1) == hash(-2) == -2), and spans no more than > sys.hash_info.modulus inte

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-25 Thread Tim Peters
[Tim] > I know the theoretical number of probes for dicts, but not for sets > anymore. The latter use a mix of probe strategies now, "randomish" > jumps (same as for dicts) but also purely linear ("up by 1") probing > to try to exploit L1 cache. > > It's not _apparent_ to me that the mix actually

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-26 Thread Tim Peters
[Tim] >> - I don't have a theory for why dict build time is _so_ much higher >> than dict lookup time for the nasty keys. To be clearer, in context this was meant to be _compared to_ the situation for sets. These were the numbers: 11184810 nasty keys dict build 23.32 dict lookup

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-27 Thread Tim Peters
[Nick Coghlan ] > I took Larry's request a slightly different way: he has a use case where > he wants order preservation (so built in sets aren't good), but combined > with low cost duplicate identification and elimination and removal of > arbitrary elements (so lists and collections.deque aren't g

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-28 Thread Tim Peters
[Larry] > Here is the original description of my problem, from the original email in > this thread. I considered this an adequate explanation of my problem > at the time. >> I do have a use case for this. In one project I maintain a "ready" list of >> jobs; I need to iterate over it, but I also w

[Python-Dev] Re: Should set objects maintain insertion order too?

2019-12-29 Thread Tim Peters
[Larry] > It's a lightweight abstract dependency graph. Its nodes are opaque, > only required to be hashable. And it doesn't require that you give it > all the nodes in strict dependency order. > > When you add a node, you can also optionally specify > dependencies, and those dependencies aren't

[Python-Dev] Re: Object deallocation during the finalization of Python program

2020-01-09 Thread Tim Peters
[Pau Freixes ] > Recently I've been facing a really weird bug where a Python program > was randomly segfaulting during the finalization, the program was > using some C extensions via Cython. There's nothing general that can be said that would help. These things require excruciating details to res

[Python-Dev] Re: Documenting Python's float.__str__()

2020-01-21 Thread Tim Peters
[Serhiy Storchaka] > This is not the only difference between '.17g' and repr(). > > >>> '%.17g' % 1.23456789 > '1.23456788' > >>> format(1.23456789, '.17g') > '1.23456788' > >>> repr(1.23456789) > '1.23456789' More amazingly ;-), repr() isn't even always the same as a %g format spe

[Python-Dev] Are PyObject_RichCompareBool shortcuts part of Python or just CPython quirks?

2020-01-23 Thread Tim Peters
PyObject_RichCompareBool(x, y, op) has a (valuable!) shortcut: if x and y are the same object, then equality comparison returns True and inequality False. No attempt is made to execute __eq__ or __ne__ methods in those cases. This has visible consequences all over the place, but they don't appea

[Python-Dev] Re: Are PyObject_RichCompareBool shortcuts part of Python or just CPython quirks?

2020-01-24 Thread Tim Peters
[Inada Naoki ] > FWIW, (list|tuple).__eq__ and (list|tuple).__contains__ uses it too. > It is very important to compare recursive sequences. > > >>> x = [] > >>> x.append(x) > >>> y = [x] > >>> z = [x] > >>> y == z > True That's a visible consequence, but I'm afraid this too must be considered an

[Python-Dev] Re: Are PyObject_RichCompareBool shortcuts part of Python or just CPython quirks?

2020-01-24 Thread Tim Peters
[Terry Reedy ] > ... > It is, in the section on how to understand and use value comparison > *operators* ('==', etc.). > https://docs.python.org/3/reference/expressions.html#value-comparisons > > First "The default behavior for equality comparison (== and !=) is based > on the identity of the objec

[Python-Dev] Re: Are PyObject_RichCompareBool shortcuts part of Python or just CPython quirks?

2020-01-24 Thread Tim Peters
[Tim] >> I think it needs more words, though, to flesh out what about this is >> allowed by the language (as opposed to what CPython happens to do), >> and to get closer to what Guido is trying to get at with his >> "*implicit* calls". For example, it's at work here, but there's not a >> built-in

[Python-Dev] Re: Are PyObject_RichCompareBool shortcuts part of Python or just CPython quirks?

2020-01-24 Thread Tim Peters
[Terry Reedy ] ]& skipping all the parts I agree with] > ... > Covered by "For user-defined classes which do not define __contains__() > but do define __iter__(), x in y is True if some value z, for which the > expression x is z or x == z is true, is produced while iterating over y. > " in > > ht

[Python-Dev] Re: Python library for the ServiceNow REST API

2020-01-28 Thread Tim Peters
[Guido] > Honestly that looked like a spammer. I approved the message, and it looked like "probably spam" to me too. But it may have just been a low-quality message, and the new moderator UI still doesn't support adding custom text to a rejection message. Under the old system, I _would_ have rejec

[Python-Dev] Re: Are PyObject_RichCompareBool shortcuts part of Python or just CPython quirks?

2020-02-03 Thread Tim Peters
[Tim] >> PyObject_RichCompareBool(x, y, op) has a (valuable!) shortcut: if x >> and y are the same object, then equality comparison returns True >> and inequality False. No attempt is made to execute __eq__ or >> __ne__ methods in those cases. >> ... >> If it's intended that Python-the-language req

[Python-Dev] Re: How to enable tracemalloc for the test suite?

2020-04-04 Thread Tim Peters
[Skip Montanaro ] > I've got a memory issue in my modified Python interpreter I'm trying > to debug. Output at the end of the problematic unit test looks like this: To my eyes, you left out the most important part ;-) A traceback showing who made the fatal free() call to begin with. In debug mod

[Python-Dev] Re: How to enable tracemalloc for the test suite?

2020-04-04 Thread Tim Peters
[Skip Montanaro ] > ... > I thought setting PYTHONTRACEMALLOC should provoke some useful output, > but I was confused into thinking I was (am?) still missed something > because it continued to produce this message: > > Enable tracemalloc to get the memory block allocation traceback Ah, I overlooke

[Python-Dev] Re: How to enable tracemalloc for the test suite?

2020-04-05 Thread Tim Peters
For posterity, just recording best guesses for the other mysteries left hanging: - PYTHONTRACEMALLOC didn't work for you because Victor's traceback showed that Py_FinalizeEx was executing _PyImport_Fini,, one statement _after_ it disabled tracemalloc via _PyTraceMalloc_Fini. - The address passed

[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020-06-24 Thread Tim Peters
You got everything right the first time ;-) The PEP is an extended illustration of "although that way may not be obvious at first unless you're Dutch". I too thought "why not else:?" at first. But "case _:" covers it in the one obvious way after grasping how general wildcard matches are. Introduc

[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020-06-24 Thread Tim Peters
[Tim] >> ".NAME" grated at first, but extends the idea that dotted names are >> always constant value patterns to "if and only if". So it has mnemonic >> value. When context alone can't distinguish whether a name is meant as >> (in effect) an lvalue or an rvalue, no syntax decorations can prevent >

[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020-06-24 Thread Tim Peters
[Ethan Furman ] > "case _:" is easy to miss -- I missed it several times reading through the > PEP. As I said, I don't care about "shallow first impressions". I care about how a thing hangs together _after_ climbing its learning curve - which in this case is about a nanometer tall ;-) You're no

[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020-06-24 Thread Tim Peters
[Taine Zhao ] > "or" brings an intuition of the execution order of pattern matching, just > like how people already know about "short-circuiting". > > "or" 's operator precedence also suggests the syntax of OR patterns. > > As we have "|" as an existing operator, it seems that there might be > cas

[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020-06-25 Thread Tim Peters
[Rhodri James ] > I'm seriously going to maintain that I will forget the meaning of "case > _:" quickly and regularly, Actually, you won't - trust me ;-) > just as I quickly and regularly forget to use > "|" instead of "+" for set union. More accurately, I will quickly and > regularly forget th

[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020-06-25 Thread Tim Peters
[Tim] See reply to Glenn. Can you give an example of a dotted name that is not a constant value pattern? An example of a non-dotted name that is? If you can't do either (and I cannot)), then that's simply what "if [Rhodri James ] >>> case long.chain.of.attributes: [Tim] >> Tha

[Python-Dev] Re: Lists placed into Emergency Moderation status

2020-06-29 Thread Tim Peters
[Ernest W. Durbin III ] > At the request of the list moderators of python-ideas and python-dev, > both lists have been placed into emergency moderation mode. All > new posts must be approved before landing on the list. > > When directed by the list moderators, this moderation will be disabled. I d

[Python-Dev] Re: Lists placed into Emergency Moderation status

2020-06-29 Thread Tim Peters
[Ernest W. Durbin III ] > Reviewing, I may have misinterpreted the message from PSF Executive > Director regarding the situation. > > It does appear that python-ideas moderators contacted postmaster@. > Appears I misread a message saying “it looks like it’s happening on > python-dev too” to mean th

[Python-Dev] Re: Lists placed into Emergency Moderation status

2020-06-30 Thread Tim Peters
t looks like it’s happening on >>> python-dev too” to mean that the request was for both lists. [Tim Peters] >> It depends on who you want to annoy least ;-) >> >> If it's the position of the PSF that some kind(s) of messages must be >> suppressed, then I'll

[Python-Dev] Re: Please refrain from posting on the PEP 8 threads for 24 hours

2020-06-30 Thread Tim Peters
[Brett Cannon wrote:] > Regardless of what side you fall on, I think we can agree that > emotions are running very high at the moment. Nothing is going > to change in at least the next 24 hours, so I am personally > asking folks to step back for at least that long and think about: > > Is what you

[Python-Dev] Re: Please refrain from posting on the PEP 8 threads for 24 hours

2020-06-30 Thread Tim Peters
[Victor Stinner ] > If someone continues to feed the PEP 8 discussion, would it be > possible to change their account to require moderation for 1 day or > maybe even up to 1 week? I know that Mailman 3 makes it possible. I see no such capability. I could, for example, manually fiddle things so th

[Python-Dev] Re: Recent PEP-8 change

2020-07-02 Thread Tim Peters
[Paul Moore ] > (This is a genuine question, and I'm terrified of being yelled at for > asking it, which gives an idea of the way this thread has gone - but I > genuinely do want to know, to try to improve my own writing). > > What *is* the correct inclusive way to refer to an unidentified person >

[Python-Dev] Re: PEP 622 version 2 (Structural Pattern Matching)

2020-07-08 Thread Tim Peters
One microscopic point: [Guido] > ... > (if `.x` is unacceptable, it’s unclear why `^x` would be any > better), As Python's self-appointed spokesperson for the elderly, there's one very clear difference: a leading "." is - literally - one microscopic point, all but invisible. A leading caret is

[Python-Dev] Re: Deferred, coalescing, and other very recent reference counting optimization

2020-09-03 Thread Tim Peters
I'm surprised nobody has mentioned this: there are no "unboxed" types in CPython - in effect, every object user code creates is allocated from the heap. Even, e.g., integers and floats. So even non-contrived code can create garbage at a ferocious rate. For example, think about this simple function

[Python-Dev] Changing Python's string search algorithms

2020-10-13 Thread Tim Peters
Fredrik Lundh crafted our current string search algorithms, and they've served us very well. They're nearly always as fast as dumbest-possible brute force search, and sometimes much faster. This was bought with some very cheap one-pass preprocessing of the pattern (the substring to search _for_),

[Python-Dev] Re: Changing Python's string search algorithms

2020-10-14 Thread Tim Peters
Rest assured that Dennis is aware of that pragmatics may change for shorter needles. The code has always made a special-case of 1-character needles, because it's impossible "even in theory" to improve over straightforward brute force search then. Say the length of the text to search is `t`, and t

[Python-Dev] Re: Changing Python's string search algorithms

2020-10-14 Thread Tim Peters
[Guido] > Maybe someone reading this can finish the Wikipedia page on > Two-Way Search? The code example trails off with a function with > some incomprehensible remarks and then a TODO.. Yes, the Wikipedia page is worse than useless in its current state, although some of the references it lists ar

[Python-Dev] Re: Changing Python's string search algorithms

2020-10-14 Thread Tim Peters
[Steven D'Aprano ] > Perhaps this is a silly suggestion, but could we offer this as an > external function in the stdlib rather than a string method? > > Leave it up to the user to decide whether or not their data best suits > the find method or the new search function. It sounds like we can offer

[Python-Dev] Re: Changing Python's string search algorithms

2020-10-14 Thread Tim Peters
[Guido] > The key seems to be: Except none of that quoted text (which I'll skip repeating) gives the slightest clue as to _why_ it may be an improvement. So you split the needle into two pieces. So what? What's the _point_? Why would someone even imagine that might help? Why is one half then

[Python-Dev] Re: Changing Python's string search algorithms

2020-10-15 Thread Tim Peters
[Dennis Sweeney ] > Here's my attempt at some heuristic motivation: Thanks, Dennis! It helps. One gloss: > > The key insight though is that the worst strings are still > "periodic enough", and if we have two different patterns going on, > then we can intentionally split them apart. The am

[Python-Dev] Re: Changing Python's string search algorithms

2020-10-15 Thread Tim Peters
[Guido] > I am not able to dream up any hard cases -- like other posters, > my own use of substring search is usually looking for a short > string in a relatively short piece of text. I doubt even the current > optimizations matter to my uses. I should have responded to this part differently. W

[Python-Dev] Re: Changing Python's string search algorithms

2020-10-16 Thread Tim Peters
[Marco Sulla] > Excuse me if I intrude in an algorithm that I have not understood, but > the new optimization can be applied to regexps too? The algorithm is limited to searching for fixed strings. However, _part_ of our regexp implementation (the bit that looks ahead for a fixed string) will inh

Re: [Python-Dev] 2 very interesting projects - Python / Finance

2009-02-17 Thread Tim Peters
[Aahz] > ... > This is spam, and you have now jeopardized your correct posting to the > Python Job Board. The other website administrators will be informed and > we will discuss whether spamming python-dev warrants withdrawing it. To be fair, a python-dev moderator approved the posting, so in the

Re: [Python-Dev] Backport new float repr to Python 2.7?

2009-10-12 Thread Tim Peters
[Mark Dickinson] > It occurs to me that any doctests that depend on the precise form of > repr(x) are, in a sense, already broken, since 2.x makes no guarantees > about repr(x) being consistent across platforms. The doctest documentation has warned about this forever (look near the end of the "War

Re: [Python-Dev] SIGCHECK() in longobject.c

2009-10-19 Thread Tim Peters
[Mark Dickinson] > By the way, here's an example of an *almost* real-life use of million digit > calculations. > > For an elementary number theory course that I taught a while ago, there > was an associated (optional) computer lab, where the students used > Python to investigate various ideas, conj

Re: [Python-Dev] Request commit privileges for Stefan Krah

2009-12-14 Thread Tim Peters
[Mark Dickinson] > I'd like to request that Stefan Krah be granted commit privileges to the > Python > svn repository, for the sole purpose of working on a (yet to be created) > py3k-decimal-in-c branch. +1. I haven't commented on any of this, but I've watched it, and Stefan appears easy enough

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