[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-04 Thread Andrew Barnert via Python-ideas
On Mar 4, 2020, at 01:56, Mark Dickinson wrote: > >> On Wed, Mar 4, 2020 at 9:22 AM Andrew Barnert via Python-ideas >> wrote: > >> Is there any commonly used or even imaginable useful type that uses them in >> weirder ways than set and float (wh

[Python-ideas] Re: New explicit methods to trim strings

2020-03-04 Thread Andrew Barnert via Python-ideas
t keyword param that accepts any iterable of strings. So when you have a set of prefixes, you don’t have to call s.lcut(tuple(prefixes)), you just pass the set as-is to s.lstrip(strings=prefixes)). _______ Python-ideas mailing list -- [email protected]

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-04 Thread Andrew Barnert via Python-ideas
; dealing with floating point numbers. Sometimes I wonder if since Python > supports dynamic typing of results, might not do better by removing the NaN > value from Floats and Decimals, and make the operations that generate the NaN > generate an object of a special NaN type. The thing is

[Python-ideas] Re: New explicit methods to trim strings

2020-03-04 Thread Andrew Barnert via Python-ideas
via Python-ideas > wrote: > >  >> On Mar 30, 2019, at 12:30, MRAB wrote: >> >> I'd much prefer .lcut/.rcut to .cut_prefix/.cut_suffix, to match >> .lstrip/.rstrip. > > I agree that we should use either l/r or something to do with start/end. We

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-05 Thread Andrew Barnert via Python-ideas
On Mar 5, 2020, at 05:24, Richard Damon wrote: > > On 3/4/20 11:07 PM, Andrew Barnert via Python-ideas wrote: >>> On Mar 4, 2020, at 19:12, Richard Damon wrote: >>> Yes, because of the NaN issue, you sort of need an 'Almost Total Order' and >>> '

[Python-ideas] Re: IDEA: Allow override of all assignments of a built in type to be a different type

2020-03-05 Thread Andrew Barnert via Python-ideas
> On Mar 5, 2020, at 01:27, Steve Barnes wrote: > One of the lovely things about Python is that we have the capability to avoid > issues such as the vagaries of the floating point type with libraries such as > decimal and fractions. This is wonderous to me but comes with an

[Python-ideas] Re: IDEA: Allow override of all assignments of a built in type to be a different type

2020-03-05 Thread Andrew Barnert via Python-ideas
On Mar 5, 2020, at 02:11, Steve Barnes wrote: > > Comments in-line (I wish Outlook would behave sensibly) > > -Original Message- > From: Paul Moore > Sent: 05 March 2020 09:52 > To: Steve Barnes > Cc: [email protected] > Subject: Re: [Python-ideas]

[Python-ideas] Re: Magnitude and ProtoMagnitude ABCs — primarily for argument validation

2020-03-05 Thread Andrew Barnert via Python-ideas
gt;for B in C.__mro__: >if B in cls._explicit_only_registry: >return NotImplemented > >return cls._check_overrides_rich_comparison_methods(C) > >@classmethod >def _check_overrides_rich_comparison_methods(cls, C): >mro =

[Python-ideas] Re: New explicit methods to trim strings

2020-03-05 Thread Andrew Barnert via Python-ideas
On Mar 5, 2020, at 08:27, Christopher Barker wrote: > >> On Wed, Mar 4, 2020 at 8:13 PM Andrew Barnert via Python-ideas >> wrote: > >> Sorry, I thought I was replying to something from today, not a year ago. > > Which is fine — that conversation kind of p

[Python-ideas] Re: Exception for parameter errors

2020-03-10 Thread Marco Sulla via Python-ideas
r > Raised when an operation or function is applied to an object of inappropriate > type. etc. It's never stated that TypeError should be raised when the number of arguments is invalid, for example. It seems that TypeError itself is saying "now I'm used outside my scope" :-)

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-10 Thread Andrew Barnert via Python-ideas
, and 64 other characters have the same byte invisibly as their second byte.) Things that are not even that ASCII-compatible include UTF-16, EBCDIC code pages, 80s Atari encoding, etc.; they are not commonly used in real-world UNIX systems. Which I think was Random’s point.___

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-10 Thread Andrew Barnert via Python-ideas
On Mar 10, 2020, at 13:18, Christopher Barker wrote: > > Getting a bit OT, but I *think* this is the story: > > I've heard it argued, by folks that want to write Python software that uses > bytes for filenames, that: > > A file path on a *nix system can be any s

[Python-ideas] Re: prefix/suffix for bytes (was: New explicit methods to trim strings)

2020-03-11 Thread Andrew Barnert via Python-ideas
On Mar 11, 2020, at 03:07, Steven D'Aprano wrote: > > But bytes are useful for more than just file names! The paradigm example of this is HTTP. It’s mostly people working on HTTP clients, servers, middleware, and apps who pushed for the bytes methods in Python 3.x. IIRC, the PE

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-11 Thread Andrew Barnert via Python-ideas
ike much of a problem, much less a problem worth breaking fundamental truthiness for a builtin type. ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-12 Thread Marco Sulla via Python-ideas
y surprised me. I had to add a boolean() function in my little msutils module, that works also for ndarrays. And the reason ndarray do this is because it also override __eq__(): https://github.com/numpy/numpy/issues/15573 _______ Python-ideas mailing list --

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
ove x` might be more understandable, but adding new keywords is expensive > > ## Optional extension > > For consistency, `x = (del foo.attr)` and `x = (del foo[i])` could also > become legal expressions, and `__delete__`, `__delattr__`, and `__delitem__` > would now have

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-12 Thread Christopher Barker via Python-ideas
On Thu, Mar 12, 2020 at 5:50 AM Marco Sulla via Python-ideas < [email protected]> wrote: > Actually, this is the behaviour of ndarray with any dtype. And IMHO > ithis is quite terrible? I can see how you would think that. But the fact is that element-wise operations are ve

[Python-ideas] Re: More appropriate behavior for the NotImplemented object

2020-03-12 Thread Marco Sulla via Python-ideas
ements collections.abc.Sequence, even if it's really not true. Like dict: >>> help(dict) Help on class dict in module builtins: class dict(object) [...] >>> issubclass(dict, MutableMapping) True _______ Python-ideas mailing list -- p

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
easy to write, read, and debug because the language and stdlib were designed around move, rather than it being retrofitted in. Obviously you’re not proposing to turn Python into a big mess like C++, but you are proposing to add complexity for something that can only be a micro optimization that we

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
's a reference that can't be deleted, until the current scope is not finished. This in practice will break `del variable` _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://m

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
new language, the loop variable would be a new binding (a separate variable) each time through, because I think that’s what people actually expect. (Everyone runs into the problem of capturing loop variables in closures —not just in Python, but in radically different languages like C++. And

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
On Mar 12, 2020, at 10:52, Marco Sulla via Python-ideas wrote: > > On Thu, 12 Mar 2020 at 18:19, Chris Angelico wrote: >> No, it wouldn't - the use of the value as a return value counts as a >> reference. It's exactly the same as any other function that returns a

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
bjects. I quote: > Heuristicly it seems to be beneficial around 400kb array sizes (which is > about the typical L2 cache size). I think anyway that this could be a good idea, without changing `del`. The problem is: how can Python knows that a generic operation will create a temporary varia

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
d have been popped earlier. Compilers for lots of other languages routinely do this kind of static analysis even though it’s a lot more complicated in, say, C++ than in Python. But I don’t think that would actually help this case. Each temporary is immediately consumed by the next opcode, not dis

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
altogether. Exactly. But if `x = None` will return the previous value of x, the refcount of the object will be not decreased, and Python does not free the object memory. An example: (venv) marco@buzz:~/sources$ python Python 3.8.2 (tags/v3.8.2-dirty:7b3ab5921f, Mar 1 2020, 16:16:55) [GCC 9.2.0]

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
ement ends, it has no effect on speed. On the contrary, for what I have read, the numpy patch removes the temporary ndarrays immediately. This speeds up calcula with large ndarrays. So there's no need to change the `del` behaviour. Python could implement something similar to the numpy patch

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
uldn’t need the C > frame hackery. But that seems like it would slow down everything in exchange > for occasionally helping numpy and a few other C extension libs. The author of the patch says this is already implemented in string concatenation in Python itself. Maybe we should look at the impl

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
king refs==1 is could check refs==1 && !c_flagged, and then it wouldn’t >> need the C frame hackery. But that seems like it would slow down everything >> in exchange for occasionally helping numpy and a few other C extension libs. > > The author of the patch says this is al

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
l is that `(del bc) + d` would enter `bc.__add__(d)` with > `self` passed with a refcount of 1. So your proposal doesn’t help their problem. At best, it gives them the same behavior they already have, which they still need to optimize. ___ Python-ideas

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
On Thu, 12 Mar 2020 at 18:42, Andrew Barnert via Python-ideas wrote: > What if a for loop, instead of nexting the iterator and binding the result to > the loop variable, instead unbound the loop variable, nexted the Iterator, > and bound the result to the loop variable? I missed that.

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
c and d are all ndarrays, the temporary objects are discard as soon as they are no more referenced, instead of at the end of the statement. He thought that the change of `del` he proposed will give him that behavior, but this is not true. And I don't think it's very much simple to implement

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
t's done by Python also for strings. Maybe it's an old "feature"? Since it seems this happens for _every_ object. I tried to install numpy version 1.14.0rc1, the latest version before the patch, but it's not compatible with python 3.8, since PyThreadState was changed in Pyt

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
On Mar 12, 2020, at 14:32, Marco Sulla via Python-ideas wrote: > On Thu, 12 Mar 2020 at 21:22, Chris Angelico wrote: >> They actually ARE already discarded > > 0O > You're right. So *how* can juliantaylor said he measured a speedup of > 2x for large ndarrays?

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
but it's removed after the reassignment. This was not very clear in Eric Wieser's example, since the size of the iterable was too short. I suppose Python, as Andrew Barnert suggested, can immediately discard the old object for comprehensions. But, really, I don't see a very big advantag

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
On Mar 12, 2020, at 13:22, Marco Sulla wrote: > > On Thu, 12 Mar 2020 at 18:42, Andrew Barnert via Python-ideas > wrote: >> What if a for loop, instead of nexting the iterator and binding the result >> to the loop variable, instead unbound the loop variable, nexted

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
??? We are saying the same thing. On Thu, Mar 12, 2020 at 11:18 AM Marco Sulla via Python-ideas wrote: > This speedup is observed only for large objects On Fri, 13 Mar 2020 at 00:45, Ben Rudiak-Gould wrote: > it's only beneficial to try it when the array

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
Deleting Thing(abcd) - ID: 140185716001088 As you can see, Thing(abcd) has the same id of Thing(ab). So what Eric Wieser wanted is already implemented in Python, for temporary objects. _______ Python-ideas mailing list -- python-ideas@python.

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Marco Sulla via Python-ideas
observations are done by benchmarks. In the real world, how can you be sure that L2 cache is not already filled up? :-) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https

[Python-ideas] Re: Make `del x` an expression evaluating to `x`

2020-03-12 Thread Andrew Barnert via Python-ideas
> On Mar 12, 2020, at 17:47, Marco Sulla > wrote: > > Well, so all this discussion is only for freeing _one_ memory location > earlier? Basically, yes. And now I get why you were confused—you’re not confused about Python, you’re confused about the proposal, because you expe

[Python-ideas] Re: [email protected] post from [email protected] requires approval

2020-03-13 Thread Brett Cannon via Python-ideas
These are coming in fine because they are not handled by Mailman's filtering rules. And the reason for the holds is they are being flagged for " Message has implicit destination". On Fri, Mar 13, 2020 at 8:06 AM Marco Sulla < [email protected]> wrote:

[Python-ideas] Re: SQL string prefix idea

2020-03-15 Thread Rob Cliffe via Python-ideas
On 22/02/2020 06:26, Steven D'Aprano wrote: Actually, in Python, regexes are the primary reason raw strings were added! Raw strings aren't quite fully raw, which is why you can't use raw strings for Windows paths: path = r'somewhere\some\folder\' doesn't

[Python-ideas] Re: Adding a built-in data structure with binary search tree semantics

2020-03-15 Thread Andrew Barnert via Python-ideas
rty lib to work through three versions of Python… One library, blist (a wide hybrid b-tree-like design) got somewhat popular, and its author proposed it to be added to the stdlib, offering to maintain it. But he wanted to also replace list and str with ropes built on the same foundation, which no

[Python-ideas] Re: dunder methods for encoding & prettiness aware formal & informal representations

2020-03-16 Thread Andrew Barnert via Python-ideas
rarely use the ∞ symbol for any of them. But people definitely do use the ∞ symbol for the projective infinity (the single point added to the real line to create the projective circle), and its complex equivalent (the single point added to the complex plan to give you the Riemann sphere).

[Python-ideas] Re: Adding a built-in data structure with binary search tree semantics

2020-03-16 Thread Andrew Barnert via Python-ideas
> On Mar 16, 2020, at 00:13, Ben Rudiak-Gould wrote: > > On Sun, Mar 15, 2020 at 9:41 PM Andrew Barnert via Python-ideas > wrote: >> Do you really want to require “binary”? > > I don't think so; they never talked about binary trees, only "binary > search

[Python-ideas] Re: dunder methods for encoding & prettiness aware formal & informal representations

2020-03-16 Thread Andrew Barnert via Python-ideas
he reason we call complex addition “addition” in the first place. And C-bar built in this way continues R-bar in the same way C continues R. And the C-style approximation of C-bar with IEEE float approximately continues IEEE float in the same way (albeit sadly not always with the same bounds of approximatio

[Python-ideas] Re: Adding a built-in data structure with binary search tree semantics

2020-03-16 Thread Andrew Barnert via Python-ideas
looking first. At any rate, I still stand by the point that nobody is going to expect O(1) copies for sorteddict when list, dict, etc. don’t do it. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-idea

[Python-ideas] Re: Adding a built-in data structure with binary search tree semantics

2020-03-16 Thread Andrew Barnert via Python-ideas
l never to insert any NaN values. Since Python containers are heterogeneous, the requirement has to be specified on the values rather than the types, just like the requirement on hashability for dict. Which means you could legally use non-NaN floats as keys. (It‘a still often a bad idea, fo

[Python-ideas] Re: Adding a built-in data structure with binary search tree semantics

2020-03-16 Thread Andrew Barnert via Python-ideas
ava, etc. don’t provide anything like that, only sorted dicts, sets, and multisets. (C# does have a SortedList, but it doesn’t act like a list, it acts like an ItemsView, in Python terms.) And it’s rare that you need something that’s sorted but also directly indexable; when you do, the answer in

[Python-ideas] Re: dunder methods for encoding & prettiness aware formal & informal representations

2020-03-16 Thread Rob Cliffe via Python-ideas
olutely no offence to anyone involved. Rob Cliffe On 16/03/2020 17:33, Andrew Barnert via Python-ideas wrote: On Mar 16, 2020, at 02:54, Stephen J. Turnbull wrote: Andrew Barnert writes: Well, there are an infinite number of ever larger infinite ordinals, ω or ω_0 being the first one, and l

[Python-ideas] Re: New explicit methods to trim strings

2020-03-18 Thread Rob Cliffe via Python-ideas
es of course] Rob Cliffe _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python

[Python-ideas] Re: Syntax for loop invariants

2020-03-18 Thread Andrew Barnert via Python-ideas
t, by adding whatever code you want that gets run before and after the statement. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-idea

[Python-ideas] Re: decorator vs. 'with' analogy [was: Syntax for loop invariants]

2020-03-19 Thread Andrew Barnert via Python-ideas
On Mar 19, 2020, at 06:23, Stephen J. Turnbull wrote: > > Andrew Barnert via Python-ideas writes: > >> [A] context manager seems perfect. It allows you to hint any >> statement, including a loop statement, by adding whatever code you >> want that gets run bef

[Python-ideas] Re: Adding a built-in data structure with binary search tree semantics

2020-03-19 Thread Andrew Barnert via Python-ideas
On Mar 19, 2020, at 11:29, Marco Sulla wrote: > > On Mon, 16 Mar 2020 at 22:22, Andrew Barnert via Python-ideas > wrote: >> I think the best solution is to just not have a SortedList. C++, Java, etc. >> don’t provide anything like that > > Guava has TreeMultiset: &

[Python-ideas] Re: New explicit methods to trim strings

2020-03-21 Thread Rob Cliffe via Python-ideas
06 PM Rob Cliffe via Python-ideas mailto:[email protected]>> wrote: Consider that the start or end of a string may contain repetitions of an affix. Should `-+-+-+Spam'.stripprefix('-+')  remove just the first occurence? All of them?  Does it n

[Python-ideas] Re: dunder methods for encoding & prettiness aware formal & informal representations

2020-03-21 Thread Andrew Barnert via Python-ideas
On Mar 20, 2020, at 19:32, Christopher Barker wrote: > > It’s a bit ironic: if you have a nifty idea for Python, you are often told to > try it out on your own. And if you expect it to maybe make its way into > Python, you’d want to use a dunder... > > But then, dunders ar

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Rob Cliffe via Python-ideas
thing it is a superset of), but I think there would be more danger of confusion with this new method. +0 on the proposal Rob Cliffe _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-22 Thread Andrew Barnert via Python-ideas
> On Mar 22, 2020, at 18:54, Steven D'Aprano wrote: > > Do you have an example of `A <= B and B <= A` aside from the `A == B` > case? For mathematical sets, this is either impossible by definition, or impossible by 2-line proof, depending on which definitions yo

[Python-ideas] Re: About python3 on windows

2020-03-23 Thread Andrew Barnert via Python-ideas
> On Mar 23, 2020, at 11:16, Frédéric De Jaeger wrote: > > The command: > >python myscript.py > > launches python3 on windows and python2 on 99% of the unix market. While that’s true for Mac 10.14, Ubuntu 18.04 LTS, etc., I think almost everyone is deprecating Pyth

[Python-ideas] Re: New explicit methods to trim strings

2020-03-23 Thread Andrew Barnert via Python-ideas
t; "\xe1" and vice versa (just as those two strings don't compare equal). Agreed, but I think it’s not just “to start with”, but forever, or at least as long as Python strings are sequences of Unicode code points. If "Café".startswith("Cafe\u0301") is false, &qu

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Rob Cliffe via Python-ideas
to compare sets. (Perhaps issubset/issuperset should not accept non-set iterables, but that ship has sailed.) Rob Cliffe _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3

[Python-ideas] Re: New explicit methods to trim strings

2020-03-23 Thread Andrew Barnert via Python-ideas
t;> the simple and straight-forward option of case sensitivity and precise >>> matching. Removing a prefix of "a\u0301" will not remove a leading >>> "\xe1" and vice versa (just as those two strings don't compare equal). >> >> Agreed, but I

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-23 Thread Andrew Barnert via Python-ideas
you’re right that it’s rare enough (and easy enough to work around) that we don’t need to add anything in the first place. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://m

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-24 Thread Andrew Barnert via Python-ideas
aticians want to say two sets are > equal, they say they are equal, they don't use the term “coextensive”. Sure, but in math, just as in Python, a set is never equal to a list (with a tiny foundations asterisk that isn’t relevant, but I’ll mention it below). So when mathematicians

[Python-ideas] Re: Instance method to test equivalence between set and iterable

2020-03-24 Thread Rob Cliffe via Python-ideas
On 23/03/2020 23:49, Steven D'Aprano wrote: On Mon, Mar 23, 2020 at 02:05:49PM +, Rob Cliffe via Python-ideas wrote: s = set("a") t = list("aa") s.issubset(t) True s.issuperset(t) True but it would be misleading IMO to say that s and t are in some sense equ

[Python-ideas] Re: About python3 on windows

2020-03-25 Thread Andrew Barnert via Python-ideas
ible that some peoplehave workflows that need versioned > executables, rather than simply using absolute paths or the launcher). The obvious exception is exactly the one the OP has: they work primarily in Cygwin, but use native Windows rather than Cygwin Python, so it’s Cygwin bash scripts (and

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-29 Thread Andrew Barnert via Python-ideas
> buf += "foo" > print(buf) > > An alternative is to use a buffer-like object explicitly designed for > incremental updates, which for Python is io.StringIO: It’s usually an even better alternative to just put the strings into a list of strings (or to write a generator that yie

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-30 Thread Andrew Barnert via Python-ideas
specific, not guaranteed, and not accessible from Python even in CPython.) And, even if that were a good idea for implementation reasons, why should the user care? If they need a mutable string, why do they care whether you give them one that inherits from or delegates to a StringIO instead of a

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-30 Thread Andrew Barnert via Python-ideas
xamples, it’s hard not to call the string concatenation optimization a win. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.p

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-30 Thread Andrew Barnert via Python-ideas
want to build it yourself, I doubt it’s possible to make a pure-Python version that’s efficient enough for real use in CPython; you’d probably need a C accelerator just to avoid the cost of boxing and unboxing between ints and single-char strings for most operations. However, you probably coul

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-30 Thread Andrew Barnert via Python-ideas
if there's io.StringIO > in the first place? Because io.StringIO does _not_ need to do that. It’s documented to act like a TextIOWrapper around a BytesIO. And the pure-Python implementation (as used by some non-CPython implementations of Python) is actually implemented that way: https://gi

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-30 Thread Andrew Barnert via Python-ideas
. So, if this memory issue makes join unacceptable, it makes your optimization even more unacceptable. And thinking about portable code makes it even worse. Your code might be run under CPython and take even more memory, or it might be run under a different Python implementation where StringIO is n

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Andrew Barnert via Python-ideas
On Mar 30, 2020, at 22:03, Steven D'Aprano wrote: > > On Mon, Mar 30, 2020 at 01:59:42PM -0700, Andrew Barnert via Python-ideas > wrote: > > [...] >> When you call getvalue() it then builds a Py_UCS4* >> representation that’s in this case 4x the size of the fin

[Python-ideas] Re: Issue 34850: Syntax Warning in the real world (is 0 / is 1)

2020-03-31 Thread Andrew Barnert via Python-ideas
ants but don’t intern small ints, “is 1” will be true for a value that the compiler could reduce to a constant, but false for one that had to be computed at runtime). If you’re writing code like this because you expect that all Python interpreters will always have this optimization, your code is

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Andrew Barnert via Python-ideas
, Mrs. Sent from my iPhone > On Mar 31, 2020, at 10:21, Gerrit Holl wrote: > > (needs a sponsor) > > latest version at > https://github.com/gerritholl/peps/blob/animal-friendly/pep-.rst > > PEP: > Title: Retire animal-unfriendly language > Author: Gerrit

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Andrew Barnert via Python-ideas
’t get silly. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Andrew Barnert via Python-ideas
ants or a tiger you were dealing with. Which is why we should all hunt and eat redwood trees rather than cows or bananas. And don’t even get me started on sunflowers. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-03-31 Thread Andrew Barnert via Python-ideas
just in theoretical possible implementations of Python but in multiple real life implementations, including CPython. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https

[Python-ideas] Re: Compound with .. else statement

2020-03-31 Thread Andrew Barnert via Python-ideas
re elegant. It might help your proposal to just show a small concrete and realistic example of how this workaround parallels the workaround for not having for/else, and how your proposed change would let you improve your code’s readability in exactly the same way as for/else. At least for me,

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-04-01 Thread Andrew Barnert via Python-ideas
uot;. > > Should we deprecate the word "wheel" as well, since it's a > reference to cheese? If the Cheese Shop doesn’t actually have any cheese in stock, is it actually offensive to cows? _______ Python-ideas mailing list -- python-idea

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-04-01 Thread Andrew Barnert via Python-ideas
nsequence of the accident that our script has only two classes of letter case. I’m not aware of any human scripts that have three or more classes, but do we really want a language that’s limited to human use only?___ Python-ideas mailing list -- python

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-04-01 Thread Andrew Barnert via Python-ideas
honistas, but word "clear" > is an exaggeration. From those who don't like it, the usual word is > "ugly", though I've seen more vivid epithets, like "repulsive": > https://mail.python.org/pipermail/python-list/2006-January/403480.html > >

[Python-ideas] Re: [Python-Dev] reversed enumerate

2020-04-01 Thread Andrew Barnert via Python-ideas
t do you get? You presumably don’t even need to look that up or try it out. It would be pretty confusing if it were different without the tuple. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] ht

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Andrew Barnert via Python-ideas
ge > package something > some message > I don’t think so. Objects in Python have a str for “human readers” and a repr that’s more useful for debugging. The repr is nearly always either an expression you can copy and paste to create an equivalent object, or something in angle brac

[Python-ideas] Re: Explicitly defining a string buffer object (aka StringIO += operator)

2020-04-02 Thread Andrew Barnert via Python-ideas
th time and space. Ideally, it should be more readable to people with a visceral dislike of str.join, and be significantly better in space (by not retaining all of the input strings for the entire length of the building process) on all Python implementations, and there should also be an easy

[Python-ideas] Re: Changing Package Representation On Shell

2020-04-02 Thread Andrew Barnert via Python-ideas
On Apr 2, 2020, at 13:35, Abdur-Rahmaan Janhangeer wrote: > >> On Thu, Apr 2, 2020 at 8:15 PM Andrew Barnert wrote: >> >> Why should modules break all of that, and be different from strings, tuples, >> functions, classes, etc.? > > python-ideas is

[Python-ideas] Re: macaddress or networkaddress module

2020-04-04 Thread Andrew Barnert via Python-ideas
On Apr 4, 2020, at 12:45, Pete Wicken wrote: > >  > Agreed that this could be achieved by a third party library; and probably > already is - but the ipaddress module in Python could also have been one. Well, it was. Go read PEP 3144 that added it, and the discussion threads beh

[Python-ideas] Re: macaddress or networkaddress module

2020-04-04 Thread Andrew Barnert via Python-ideas
e helpful. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@p

[Python-ideas] Re: macaddress or networkaddress module

2020-04-05 Thread Andrew Barnert via Python-ideas
rm of layer 2 addressing. I think Python is just following history here. It has nice wrappers for everything C/POSIX/Sockets exposed, and then it has higher-level libraries for all the protocols that were really important in the early 90s, and that’s it. And then it has selectors and asyncio

[Python-ideas] Re: macaddress or networkaddress module

2020-04-05 Thread Andrew Barnert via Python-ideas
> On Apr 5, 2020, at 20:12, Stephen J. Turnbull > wrote: > > Andrew Barnert via Python-ideas writes: > >> However, I think that a macaddress library could easily be one of >> the few things that does properly fit in the networking section of >> the stdlib. It

[Python-ideas] Re: Improvement: __json__

2020-04-06 Thread Andrew Barnert via Python-ideas
f course JSON isn’t perfect, as anyone who’s tried to interchange, say, int64 values discovers… but it’s good enough for many applications.) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-i

[Python-ideas] Re: Improvement: __json__

2020-04-06 Thread Andrew Barnert via Python-ideas
ould be creating a simple > class for something like a REST API and that class having a __json__ > function. Python doesn't need to deserialise the JSON, so you only need one > half of the story, the half that __json__ would make easier. For the vast majority of people writing web serv

[Python-ideas] Re: Improvement: __json__

2020-04-07 Thread Andrew Barnert via Python-ideas
e pretty cool. This seems like one of the many things that’s impossible to do for Python classes with full generality, but pretty easy to do if you only want to support @dataclass. Either dynamically or statically, in fact. You could even write a tool that generates dataclasses (statically or

[Python-ideas] Re: "except BaseException with f as result"

2020-04-07 Thread Andrew Barnert via Python-ideas
ing bound to something to do with f. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/l

[Python-ideas] Re: Improvement: __json__

2020-04-08 Thread Andrew Barnert via Python-ideas
data according to. > > I think generating some amalgamation of JSONLD @context & SHACL and JSON > schema would be an interesting exercise. You'd certainly want to add more > information to the generated schema than just the corresponding Python types : > - type URI(s) that c

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Andrew Barnert via Python-ideas
e and keep x alive? Maybe that’s ok. After all, that code doesn’t work in a Python implementation that doesn’t have stack frame support. Some of the other possibilities might be more portable, but I don’t know without digging in further. Or maybe you can add new restrictions to what locals and

[Python-ideas] Re: Improvement: __json__

2020-04-08 Thread Andrew Barnert via Python-ideas
On Apr 8, 2020, at 01:18, Wes Turner wrote: > > I don't see the value in using JSON to round-trip from Python to the same > Python code. > > External schema is far more useful than embedding part of an ad-hoc nested > object schema in type annotations that can't

[Python-ideas] Re: Improvement: __json__

2020-04-08 Thread Andrew Barnert via Python-ideas
On Apr 8, 2020, at 12:55, Wes Turner wrote: > > We should welcome efforts to support linked data in Python. Fine, but that’s doesn’t meant we should derail every proposal that has anything to do with JSON by turning it into a proposal for linked data, or consider a useful proposal

[Python-ideas] Re: Optimize out unused variables

2020-04-08 Thread Andrew Barnert via Python-ideas
d see if there are any cases where it’s useful, but only with the restrictions relaxed, and maybe use that as a guide to whether it’s worth finding a way to aim for looser restrictions in the first place or not. ___ Python-ideas mailing list -- py

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-09 Thread Andrew Barnert via Python-ideas
ence some member of a struct at address 1, which means trying to access an int or pointer or whatever at address 1 or 9 or 17 or whatever. On most platforms, those addresses are going to be unmapped (and, on some, illegally aligned to boot), so you’ll get a segfault. This has nothing to do with the G

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-09 Thread Andrew Barnert via Python-ideas
com/docs/blazingsql This isn’t relevant here at all. How objects get constructed and manage their internal storage is completely orthogonal to the how Python manages object lifetimes. > … New #DataFrame Interface and when that makes a copy for 2x+ memory use > - "A dataframe protoco

<    6   7   8   9   10   11   12   13   14   15   >