Re: NoneType List
On Mon, 02 Jan 2023 13:59:03 -0800 (PST), Grant Edwards wrote: > Yonks ago (early 80s), I used Pascal to write an RTOS kernel and call > processing firmware for a cell-site radio running a 16-bit > microprocessor (Z8000). It worked great. However, that Pascal compiler > had a few extensions designed specifically to support embedded systems > use on bare metal -- things like specific length signed/unsigned > interger types (with binary operations), pointers to raw memory and > configurable bounds-checking. Around that time I had a source of income from writing extensions. My client tended to hire engineers fro the University of Maine where Pascal was the didactic language. Wirth's Pascal was characterized as a language very good at telling secrets to itself. Controlling robotic arms, gathering information from process controllers, and so forth wasn't on the menu. As for Turbo Pascal, I had been using the BDS C subset on a CP/M system. I installed TP, did the requisite hello world, and I thought something was broken. I had to convince myself the compiler had spit out an executable that fast and hadn't crashed. -- https://mail.python.org/mailman/listinfo/python-list
Re: NoneType List
On 1/2/2023 5:01 PM, Grant Edwards wrote: On 2023-01-02, Alan Gauld wrote: On 02/01/2023 02:14, avi.e.gr...@gmail.com wrote: I used PASCAL before C and I felt like I was wearing a straitjacket at times in PASCAL when I was trying to write encryption/decryption functions and had to find ways to fiddle with bits. Similar things were easy in C, and are even easier in many more recent languages such as Python. That's true of pure Pascal. But Thomas was talking about Turbo Pascal which had extra functions and features for all those "real world" type things. (And you could insert some inline assembler if all else failed) It also relaxed the ludicrously strict typing slightly. Turbo Pascal made Pascal a joy and I still use Delphi for Windows programming today. TP also introduced classes to Pascal (although Apple had already done so for the Mac and Borland basically ported the syntax to the PC). TP was indeed a joy to work with. It made it trivial to do simple graphics on an IBM-PC and it was FAST -- both to write in, to debug, and in raw execution speed. FAST, yes, even with 256K memory and only floppy drives - my first PC (compatible) machine. -- https://mail.python.org/mailman/listinfo/python-list
Re: NoneType List
On 2023-01-02, Alan Gauld wrote: > On 02/01/2023 02:14, avi.e.gr...@gmail.com wrote: >> I used PASCAL before C and I felt like I was wearing a straitjacket at times >> in PASCAL when I was trying to write encryption/decryption functions and had >> to find ways to fiddle with bits. Similar things were easy in C, and are >> even easier in many more recent languages such as Python. > > That's true of pure Pascal. But Thomas was talking about Turbo Pascal > which had extra functions and features for all those "real world" type > things. (And you could insert some inline assembler if all else failed) > It also relaxed the ludicrously strict typing slightly. Turbo Pascal > made Pascal a joy and I still use Delphi for Windows programming today. > > TP also introduced classes to Pascal (although Apple had already done > so for the Mac and Borland basically ported the syntax to the PC). TP was indeed a joy to work with. It made it trivial to do simple graphics on an IBM-PC and it was FAST -- both to write in, to debug, and in raw execution speed. -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: About the Python
On 1/1/23 22:27, Ramya M wrote: > This is from JNN College of Engineering, Shimoga. we are facing some > problems while using python. Please can you resolve this issue. Without any further information on your part, we can only guess at what the problems might be. Crystal ball says that Thomas' suggestion will probably solve your problem. But since we don't know what the problems even are, this is just a wild guess. > We are using python 3.11.1 (64 bit) for windows 10. but while installing > the "numpy and matplotlib" packages we are getting errors. In some cases > after installation of the above said packages we are getting errors while > working. You'll need to provide more information than that. What are these errors? Copy and paste the text into your message. Attachments are not allowed on this list. -- https://mail.python.org/mailman/listinfo/python-list
Re: NoneType List
On 2023-01-02, wrote: > I used PASCAL before C and I felt like I was wearing a straitjacket at times > in PASCAL when I was trying to write encryption/decryption functions and had > to find ways to fiddle with bits. Similar things were easy in C, and are > even easier in many more recent languages such as Python. Yonks ago (early 80s), I used Pascal to write an RTOS kernel and call processing firmware for a cell-site radio running a 16-bit microprocessor (Z8000). It worked great. However, that Pascal compiler had a few extensions designed specifically to support embedded systems use on bare metal -- things like specific length signed/unsigned interger types (with binary operations), pointers to raw memory and configurable bounds-checking. Even with wide use of those extensions it was easier to write code that "worked the first time" than it was with C. This was in the early 80's, and C compilers didn't hold your hand as much as they do today. -- Grant -- https://mail.python.org/mailman/listinfo/python-list
[Python-announce] tencdec: A number array to/from bytes high performance encoder/decoder
# What is tencdec A number array to/from bytes high performance encoder/decoder. It gets a list of monotonic increasing integers and can encode it to a byte object very fast in a compressed form using deltas. Then you may store that byte object in a DB or whatever, and when you need the list of integers back, you just decode it. https://github.com/facundobatista/tencdec Example: ``` >>> numbers = [0, 1, 2, 3, 4, 28, 87, 87, 500, 501, 507, 2313] >>> enc = tencdec.encode(numbers) >>> enc b'\x00\x01\x01\x01\x01\x18;\x00\x9d\x03\x01\x06\x8e\x0e' >>> dec = tencdec.decode(enc) >>> numbers == dec True ``` And it's very fast! Using the numbers from the example above, `timeit` shows around 2 microseconds to encode or decode (in a AMD Ryzen 7 PRO 4750U CPU): ``` $ python3 -m timeit -s "import tencdec; numbers = [0, 1, 2, 3, 4, 28, 87, 87, 500, 501, 507, 2313]" "tencdec.encode(numbers)" 10 loops, best of 5: 2.28 usec per loop $ python3 -m timeit -s "import tencdec; e = tencdec.encode([0, 1, 2, 3, 4, 28, 87, 87, 500, 501, 507, 2313])" "tencdec.decode(e)" 10 loops, best of 5: 2.42 usec per loop ``` The restriction are that numbers need to be integers (else encoding will crash with `TypeError`) and monotonic increasing positive (this is verified, otherwise it gets into an infinite loop, but with an `assert` so you may disable the verification running Python with `-O` if you are already sure that list of numbers is ok). Note that there are no external dependencies for this. It's just Python 3 and its standard library. -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org.ar/ Twitter: @facundobatista ___ Python-announce-list mailing list -- python-announce-list@python.org To unsubscribe send an email to python-announce-list-le...@python.org https://mail.python.org/mailman3/lists/python-announce-list.python.org/ Member address: arch...@mail-archive.com
Re: Fwd: About the Python
On 1/2/23 10:32, Thomas Passin wrote: Since you have an immediate need to have working installations, I suggest that you downgrade to an earlier version of Python. V3.11.1 is new and some binary libraries (such as numpy) may not be working correctly yet with the latest version. Your students will not need any of the new features that 3.11 may provide. On 1/2/2023 12:27 AM, Ramya M wrote: -- Forwarded message - From: Ramya M Date: Mon, Jan 2, 2023, 9:58 AM Subject: About the Python To: This is from JNN College of Engineering, Shimoga. we are facing some problems while using python. Please can you resolve this issue. We are using python 3.11.1 (64 bit) for windows 10. but while installing the "numpy and matplotlib" packages we are getting errors. In some cases after installation of the above said packages we are getting errors while working. So, Please can you people resolve this issue as the python labs are going on and students are facing some difficulties. Thanking you Regards Ramya M Instructor, ECE Dept. JNNCE, Shimoga Second these comments... you don't have to be in a rush to upgrade to a new Python if there are a lot of complex dependencies. There's a site where you can do a quick check for some of the more popular addons: https://pyreadiness.org That said, the packages you mention should be available for 3.11 - though there could be some dependencies in your chain causing problems. You haven't given any actionable information. "Getting errors" is a meaningless statement without details. People minded to help aren't going to be able to do so. -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: About the Python
Since you have an immediate need to have working installations, I suggest that you downgrade to an earlier version of Python. V3.11.1 is new and some binary libraries (such as numpy) may not be working correctly yet with the latest version. Your students will not need any of the new features that 3.11 may provide. On 1/2/2023 12:27 AM, Ramya M wrote: -- Forwarded message - From: Ramya M Date: Mon, Jan 2, 2023, 9:58 AM Subject: About the Python To: This is from JNN College of Engineering, Shimoga. we are facing some problems while using python. Please can you resolve this issue. We are using python 3.11.1 (64 bit) for windows 10. but while installing the "numpy and matplotlib" packages we are getting errors. In some cases after installation of the above said packages we are getting errors while working. So, Please can you people resolve this issue as the python labs are going on and students are facing some difficulties. Thanking you Regards Ramya M Instructor, ECE Dept. JNNCE, Shimoga -- https://mail.python.org/mailman/listinfo/python-list
RE: RE: NoneType List
Alan, I stand corrected as my path never led me back to any form of PASCAL. And, frankly, my path rarely led me again to having to do what we describe as twiddling bits with the minor exception when doing something like setting the bits needed to specify what permissions should be associated with a file in the UNIX world. What you say is largely true of programming languages in general. Many are created with some paradigm in mind that sounds like an idea until it meets reality and compromises and adjustments are made. When new languages follow that have the ability to gain from prior experience, they may indeed come up with a more nuanced paradigm. I have been studying JavaScript and Node.js lately, for no special reason, and see that as an example of sorts. The former was largely created to run inside a browser and NOT do anything harmful to the user's machine. Lots of parts normally included in other programming languages such as Python were not only deliberately left out but the code often monitors some things to make sure you do not try anything sneaky. But the language took off and evolved and at some point seemed to people to be a good tool to use on their servers too, and especially since the two sides could exchange relatively live objects such as with JSON. The paradigm had to change as most such programs written in what is now Node.js or other names, actually had to do things to the server including reading and writing files. So they had to add quite a bit and struggled at times to keep other parts of the languages similar as they evolved semi-independently. In my opinion, it remains a futile work in progress. Has Python managed the version 2 versus version 3 schism to the point where enough users have migrated their code and new users avoid version 2? Other languages have had to split when big enough changes were made. -Original Message- From: Alan Gauld Sent: Monday, January 2, 2023 3:01 AM To: avi.e.gr...@gmail.com; python-list@python.org Subject: Re: RE: NoneType List On 02/01/2023 02:14, avi.e.gr...@gmail.com wrote: > I used PASCAL before C and I felt like I was wearing a straitjacket at > times in PASCAL when I was trying to write encryption/decryption > functions and had to find ways to fiddle with bits. Similar things > were easy in C, and are even easier in many more recent languages such as > Python. That's true of pure Pascal. But Thomas was talking about Turbo Pascal which had extra functions and features for all those "real world" type things. (And you could insert some inline assembler if all else failed) It also relaxed the ludicrously strict typing slightly. Turbo Pascal made Pascal a joy and I still use Delphi for Windows programming today. TP also introduced classes to Pascal (although Apple had already done so for the Mac and Borland basically ported the syntax to the PC). -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
Re: NoneType List
Thanks a lot all for your suggestions, I am clear now. On Mon, Jan 2, 2023 at 10:50 AM wrote: > Not to wax poetic about our pasts, Thomas, but I do did not start with > PASCAL and used quite a few languages before and plenty after. At the time > it had interesting contrasts to languages like BASIC, FORTRAN and LISP and > I > tended to use whatever was available on the machines I was using. My first > computer job (other than in grad school itself) was using OMSI PASCAL. I > even wrote my thesis as a PASCAL program containing comments that included > typesetting instructions in a language called RUNOFF while the PASCAL > program itself was a set of comments as far as RUNOFF was concerned. So it > compiled or was typeset and printed from the same source. > > But my next job after graduation was for Bell Labs and I had to forget all > the mainframe or DEC systems and adapt to UNIX, and of course C and later > C++ and the various other little languages that came with that such as AWK > and PERL ... > > There is no one right language but there often is a small set of right > languages given your circumstances, such as what your employer has everyone > using and especially in group projects. > > To be fair, languages like Python and R seem to keep having parts rewritten > in C or C++ to make some things run faster and can include libraries > written > ages ago in languages like FORTRAN that have been finely tuned. Under the > hood, these languages often hide parts so that developing a new python (or > R > or ...) module/package can start by writing it all in that language and > then > taking some functionality and rewriting it in the other language for > critical regions where a slower interpreted method may be speeded up. > > But for prototyping, or when speed is not a big deal, I really prefer > Python > to ... > > > -Original Message- > From: Python-list > On > Behalf Of Thomas Passin > Sent: Sunday, January 1, 2023 10:15 PM > To: python-list@python.org > Subject: Re: NoneType List > > On 1/1/2023 9:14 PM, avi.e.gr...@gmail.com wrote: > > Thomas, > > > > I used PASCAL before C and I felt like I was wearing a straitjacket at > > times in PASCAL when I was trying to write encryption/decryption > > functions and had to find ways to fiddle with bits. Similar things > > were easy in C, and are even easier in many more recent languages such > > as Python. > > PASCAL was not the first language I learned. I won't pretend I had to do > anything very complicated, or do much bit-twiddling. It was, though, the > first one (except probably for FORTH) I enjoyed programming with more than > I > disliked the boiler-plate formalities. > > > The distinction between teaching a first language, or one that is so > > cautious as to catch and prevent all mistakes it can, is not for > > people willing to be bolder or work faster or write routines that can > > be used more generally. > > > > What has not been mentioned is that languages like python go a step > > further and allow a function to return many arguments and even a > > varying number of arguments, as well as none at all. To do anything > > like that in PASCAL > > (or C, for that matter) > > > took some thought on how to make some structure you could fill out > > then return as a single value that the receiving code had to sort of > > decode and perhaps deal with parts that could hold a union of several > > things. Can a compiler or interpreter easily verify you did something > > reasonable, as compared to say python that allows something like: > > > > (res1, res2, _, res4, _, rest) = f(x) > > Yes, that's one of the good things about Python, how it makes working with > tuples so easy and natural. OTOH, harking back to PASCAL for a minute, it > had enumerations and sets long before Python got them. > > > The above tells the interpreter you expect perhaps 6 or more results > > and what to do with them. > > > > > > > > -Original Message- From: Python-list > > On Behalf Of > > Thomas Passin Sent: Sunday, January 1, 2023 1:03 PM To: > > python-list@python.org Subject: Re: NoneType List > > > > On 1/1/2023 8:47 AM, Stefan Ram wrote: > >> Thomas Passin writes: > >>> Guido had been working on the ABC language for some years before he > >>> developed Python. ABC was intended mainly as a teaching and > >>> prototyping language. > >> > >> In those days, there used to be a language called "Pascal". Pascal > >> had a dichotomy between "functions" and "procedures". A call to a > >> function was intended to have a value. A call to a procedure was > >> intended to have an effect. > > > > Wirth developed Pascal as a teaching language. IIRC, originally it was > > taught to students before there were any implementations. I did most > > of my programming with Turbo Pascal for many years. Just to clarify > > what you wrote above, in Pascal a "procedure" does not return anything > > while a "function" does. > > > > I really liked (Turbo) Pascal and I hated C back
RE: Python-list Digest, Vol 232, Issue 1
Well explained, Roger. Your explanation reminds me why some languages very deliberately do not want the C operators of pre/post increment/decrement. Similar to your argument, code in C like: Y = X++ Or Y = ++X And similarly the -- versions, have a sort of side effect of changing X either before or after the "value" is used. Code like: X += 1 Or X = X + 1 Followed by Y = X Can be longer but a tad clearer, as is code like: Y = X X -= 1 I have seen code in languages that support this that can take some head scratching to figure out when combinations using parentheses and multiple instances of ++/-- are used pre and/or post. Then again, Python added the Walrus operator recently that also allows a kind of change within an expression that can be quite useful but can be viewed as a sort of change to an object and a return of the new value. >>> x = 1 >>> y = (x := 5) >>> y 5 >>> z = (x := x * 2) + (x := x + 1) >>> z 21 >>> x 11 I posit constructs such as the above may have similarities to changing an object and returning the new updated object. Maybe not the same but ... Avi -Original Message- From: Python-list On Behalf Of Christman, Roger Graydon Sent: Sunday, January 1, 2023 7:31 PM To: python-list@python.org Subject: Re: Python-list Digest, Vol 232, Issue 1 Re: Nonetype List In my introductory programming course, I have drawn some attention to this behavior regarding mutating lists. Indeed, Python is very consistent with its behavior: Any function that mutates a list parameter does not return that list as a return value. For one thing, there is no need to return that value, because the caller still owns the list parameter that has been modified. But secondly, (and what I find especially important), is that returning the modified list would lead too many program bugs or misunderstandings. For example, if append did return the list, you might see this: x = [1,2,3] y = x.append(4) z = y.append(5) The principal of 'least surprise' would cause a casual reader to believe that x retains the value of [1,2,3], y would have the value of [1,2,3,4], and z would contain [1,2,3,4,5]. So it would be very surprising indeed to discover that x contains [1,2,3,4,5], especially after that statement that makes no reference to x. Since append modifies the list in place, returning that list would make x, y, and z all aliases of each other, and aliasing is a source of many bugs that are very hard to find. So a recommendation that I make to my class (and which coincides with Python behavior), is to NEVER return a modified list as a return value, but only to return lists that were newly created within the function. So to support this principal of 'least surprise', the append method above would necessarily create new lists for y and z that are not aliases to x. Why Python does not do that is a very obvious cases of run-time efficiency (constant time to append vs. linear to recreate a new list). And as another observation, I have my students review all of the methods defined for the list object, and they are all very consistent. Most of them either define a return value, or modify the list parameter, but almost none do both. The sole exception is the pop() function that modified a list and returns a value, but that returned value still is not the modified list, so the aliasing problem will never arise. So, I am very happy with this Python language decision -- it allows for the most efficient means to modify a list in place and also very much reduce the danger of aliasing bugs. Roger Christman Pennsylvania State University From: Python-list on behalf of python-list-requ...@python.org Sent: Sunday, January 1, 2023 12:00 PM To: python-list@python.org Subject: Python-list Digest, Vol 232, Issue 1 Send Python-list mailing list submissions to python-list@python.org To subscribe or unsubscribe via the World Wide Web, visit https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.pytho n.org%2Fmailman%2Flistinfo%2Fpython-list=05%7C01%7Cdvl%40psu.edu%7C744c 83fc485a4b1c79db08daec19a436%7C7cf48d453ddb4389a9c1c115526eb52e%7C0%7C0%7C63 8081892123929669%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzI iLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=etYqO01OszhEpqgjLeKQTM C9b3wT0sc%2FcN8oJo9eEhk%3D=0 or, via email, send a message with subject or body 'help' to python-list-requ...@python.org You can reach the person managing the list at python-list-ow...@python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." Today's Topics: 1. Re: NoneType List (Thomas Passin) 2. Re: NoneType List (MRAB) 3. Re: NoneType List (dn) 4. RE: NoneType List (avi.e.gr...@gmail.com) 5. Re: NoneType List (Thomas Passin) 6. Re: NoneType List (Greg Ewing) 7. RE: NoneType List (avi.e.gr...@gmail.com) 8. Re: NoneType List (Chris Angelico) 9. RE:
Re: NoneType List
On 1/2/2023 3:01 AM, Alan Gauld wrote: On 02/01/2023 02:14, avi.e.gr...@gmail.com wrote: I used PASCAL before C and I felt like I was wearing a straitjacket at times in PASCAL when I was trying to write encryption/decryption functions and had to find ways to fiddle with bits. Similar things were easy in C, and are even easier in many more recent languages such as Python. That's true of pure Pascal. But Thomas was talking about Turbo Pascal which had extra functions and features for all those "real world" type things. (And you could insert some inline assembler if all else failed) It also relaxed the ludicrously strict typing slightly. Turbo Pascal made Pascal a joy and I still use Delphi for Windows programming today. If Python weren't around, I might be doing that myself. TP also introduced classes to Pascal (although Apple had already done so for the Mac and Borland basically ported the syntax to the PC). That was V5.5, wasn't it? Classes were a hugely useful extension to TP. I used a version with classes (a later version that had a graphics primitives module) to write a window manager (in DOS graphics mode, all 350 X 200 pixels of it). -- https://mail.python.org/mailman/listinfo/python-list
Fwd: About the Python
-- Forwarded message - From: Ramya M Date: Mon, Jan 2, 2023, 9:58 AM Subject: About the Python To: This is from JNN College of Engineering, Shimoga. we are facing some problems while using python. Please can you resolve this issue. We are using python 3.11.1 (64 bit) for windows 10. but while installing the "numpy and matplotlib" packages we are getting errors. In some cases after installation of the above said packages we are getting errors while working. So, Please can you people resolve this issue as the python labs are going on and students are facing some difficulties. Thanking you Regards Ramya M Instructor, ECE Dept. JNNCE, Shimoga -- https://mail.python.org/mailman/listinfo/python-list
Re: RE: NoneType List
On 02/01/2023 02:14, avi.e.gr...@gmail.com wrote: > I used PASCAL before C and I felt like I was wearing a straitjacket at times > in PASCAL when I was trying to write encryption/decryption functions and had > to find ways to fiddle with bits. Similar things were easy in C, and are > even easier in many more recent languages such as Python. That's true of pure Pascal. But Thomas was talking about Turbo Pascal which had extra functions and features for all those "real world" type things. (And you could insert some inline assembler if all else failed) It also relaxed the ludicrously strict typing slightly. Turbo Pascal made Pascal a joy and I still use Delphi for Windows programming today. TP also introduced classes to Pascal (although Apple had already done so for the Mac and Borland basically ported the syntax to the PC). -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list