Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Cameron Simpson
On 26May2021 12:11, Jon Ribbens wrote: >On 2021-05-26, Alan Gauld wrote: >> I confess I had just assumed the unicode strings were stored >> in native unicode UTF8 format. > >If you do that then indexing and slicing strings becomes very slow. True, but that isn't necessarily a show stopper. My im

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Alan Gauld via Python-list
On 26/05/2021 22:15, Tim Chase wrote: > If you don't decode it upon reading it in, it should still be 100MB > because it's a stream of encoded bytes. I usually convert them to utf8. > You don't specify what you then do with this humongous string, Mainly I search for regex patterns which can

Re: Turtle module

2021-05-26 Thread Greg Ewing
On 27/05/21 4:17 am, Chris Angelico wrote: Worst case, it is technically available as the ._fullcircle member, but I would advise against using that if you can help it! If you're worried about that, you could create your own turle subclass that tracks the state how you want. -- Greg -- https:/

Re: Turtle module

2021-05-26 Thread boB Stepp
On Wed, May 26, 2021 at 10:59 AM Michael F. Stemper wrote: > In order to turn the turtle, I need to select a way to represent > angles. I could use either degrees or radians (or, I suppose, > grads). However, for my functions to work, I need to set the > turtle to that mode. This means that I cou

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Tim Chase
On 2021-05-26 18:43, Alan Gauld via Python-list wrote: > On 26/05/2021 14:09, Tim Chase wrote: >>> If so, doesn't that introduce a pretty big storage overhead for >>> large strings? >> >> Yes. Though such large strings tend to be more rare, largely >> because they become unweildy for other reas

Re: Turtle module

2021-05-26 Thread Chris Angelico
On Thu, May 27, 2021 at 6:51 AM Michael F. Stemper wrote: > > On 26/05/2021 11.17, Chris Angelico wrote: > > On Thu, May 27, 2021 at 1:59 AM Michael F. Stemper > > wrote: > > > >>What I would like to do is capture the > >> angle-representation mode on entry and restore it on return. > >> How

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Alan Gauld via Python-list
On 26/05/2021 14:09, Tim Chase wrote: >> If so, doesn't that introduce a pretty big storage overhead for >> large strings? > > Yes. Though such large strings tend to be more rare, largely because > they become unweildy for other reasons. I do have some scripts that work on large strings - mainl

Re: Turtle module

2021-05-26 Thread Michael F. Stemper
On 26/05/2021 13.24, Stefan Ram wrote: "Michael F. Stemper" writes: What I would like to do is capture the angle-representation mode on entry and restore it on return. another one: def f( turtle_ ): my_turtle = turtle_.clone() # now work with my_turtle on

Re: Turtle module

2021-05-26 Thread Michael F. Stemper
On 26/05/2021 11.17, Chris Angelico wrote: On Thu, May 27, 2021 at 1:59 AM Michael F. Stemper wrote: What I would like to do is capture the angle-representation mode on entry and restore it on return. However, looking through the methods of turtle.Turtle(), I can't find any means of captu

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Terry Reedy
On 5/26/2021 12:07 PM, Chris Angelico wrote: On Thu, May 27, 2021 at 1:59 AM Jon Ribbens via Python-list wrote: On 2021-05-26, Alan Gauld wrote: On 25/05/2021 23:23, Terry Reedy wrote: In CPython's Flexible String Representation all characters in a string are stored with the same number of

Re: Turtle module

2021-05-26 Thread Chris Angelico
On Thu, May 27, 2021 at 1:59 AM Michael F. Stemper wrote: > In order to turn the turtle, I need to select a way to represent > angles. I could use either degrees or radians (or, I suppose, > grads). However, for my functions to work, I need to set the > turtle to that mode. This means that I could

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Chris Angelico
On Thu, May 27, 2021 at 1:59 AM Jon Ribbens via Python-list wrote: > > On 2021-05-26, Alan Gauld wrote: > > On 25/05/2021 23:23, Terry Reedy wrote: > >> In CPython's Flexible String Representation all characters in a string > >> are stored with the same number of bytes, depending on the largest >

Pandas: How does df.apply(lambda work to create a result

2021-05-26 Thread Veek M
t = pd.DataFrame([[4,9],]*3, columns=['a', 'b']) a b 0 4 9 1 4 9 2 4 9 t.apply(lambda x: [x]) gives a[[1, 2, 2]] b[[1, 2, 2]] How?? When you 't' within console the entire data frame is dumped but how are the individual elements passed into .apply()? I can't do lambda x,y: [x,y]

Turtle module

2021-05-26 Thread Michael F. Stemper
I recently discovered the turtle module and have been playing around with it for the last few days. I've started writing some functions for turtles, and would like to make them a bit more robustly than what I currently have. In particular, I'd like the state of the turtle to be more or less the s

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Jon Ribbens via Python-list
On 2021-05-26, Alan Gauld wrote: > On 25/05/2021 23:23, Terry Reedy wrote: >> In CPython's Flexible String Representation all characters in a string >> are stored with the same number of bytes, depending on the largest >> codepoint. > > I'm learning lots of new things in this thread! > > Does th

exit() builtin, was Re: imaplib: is this really so unwieldy?

2021-05-26 Thread Peter Otten
On 26/05/2021 01:02, Cameron Simpson wrote: On 25May2021 15:53, Dennis Lee Bieber wrote: On Tue, 25 May 2021 19:21:39 +0200, hw declaimed the following: Oh ok, it seemed to be fine. Would it be the right way to do it with sys.exit()? Having to import another library just to end a program mi

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Tim Chase
On 2021-05-26 08:18, Alan Gauld via Python-list wrote: > Does that mean that if I give Python a UTF8 string that is mostly > single byte characters but contains one 4-byte character that > Python will store the string as all 4-byte characters? As best I understand it, yes: the cost of each "chara

Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Chris Angelico
On Wed, May 26, 2021 at 10:04 PM Alan Gauld via Python-list wrote: > > On 25/05/2021 23:23, Terry Reedy wrote: > > > In CPython's Flexible String Representation all characters in a string > > are stored with the same number of bytes, depending on the largest > > codepoint. > > I'm learning lots of

Re: learning python ...

2021-05-26 Thread Greg Ewing
On 26/05/21 7:15 pm, hw wrote: it could at least figure out which, the type or the variable, to use as parameter for a function that should specify a variable type when the name is given.  Obviously, python knows what's expected, so why not chose that. It knows, but not until *after* the func

string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Alan Gauld via Python-list
On 25/05/2021 23:23, Terry Reedy wrote: > In CPython's Flexible String Representation all characters in a string > are stored with the same number of bytes, depending on the largest > codepoint. I'm learning lots of new things in this thread! Does that mean that if I give Python a UTF8 string

Re: learning python ...

2021-05-26 Thread Chris Angelico
On Wed, May 26, 2021 at 5:49 PM hw wrote: > > On 5/25/21 10:32 AM, Chris Angelico wrote: > > On Tue, May 25, 2021 at 1:00 PM hw wrote: > >> > >> On 5/24/21 3:54 PM, Chris Angelico wrote: > >>> You keep using that word "unfinished". I do not think it means what > >>> you think it does. > >> > >> W

Re: learning python ...

2021-05-26 Thread hw
On 5/25/21 10:32 AM, Chris Angelico wrote: On Tue, May 25, 2021 at 1:00 PM hw wrote: On 5/24/21 3:54 PM, Chris Angelico wrote: You keep using that word "unfinished". I do not think it means what you think it does. What do you think I think it means? I think it means that the language is h

Re: learning python ...

2021-05-26 Thread hw
On 5/25/21 9:42 AM, Greg Ewing wrote: On 25/05/21 2:59 pm, hw wrote: Then what is 'float' in the case of isinstance() as the second parameter, and why can't python figure out what 'float' refers to in this case? You seem to be asking for names to be interpreted differently when they are used