Re: Why does not Python accept functions with no names?

2022-02-20 Thread Eryk Sun
On 2/20/22, Greg Ewing wrote: > > BTW, this is not what is usually meant by the term "anonymous > function". An anonymous function is one that is not bound > to *any* name. The thing you're proposing wouldn't be > anonymous -- it would have a name, that name being the empty > string. Sorry. I rea

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 16:48, Avi Gross via Python-list wrote: > > Amusingly, Greg, if you had a system where the un-named anonymous function > was to be named the unique value of the empty string, then a second such > anonymous function definition would over-write it, as with any named > funct

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Avi Gross via Python-list
Amusingly, Greg, if you had a system where the un-named anonymous function was to be named the unique value of the empty string, then a second such anonymous function definition would over-write it, as with any named function. The kind of anonymous function we are more used to might be something

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Grant Edwards
On 2022-02-20, Christian Gollwitzer wrote: >> For the same reason an empty sequence of characters cannot >> be a variable name. Do you know any language (or formal >> theory) that allows that? > > Tcl allows that: Interesting to know, but the fact that Tcl does something differnt is more of an a

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 14:36, Python wrote: > > Barry wrote: > > > > > >> On 20 Feb 2022, at 15:35, Abdur-Rahmaan Janhangeer > >> wrote: > >> > >> Greetings list. > >> > >> Out of curiosity, why doesn't Python accept > >> def (): > >> return '---' > >> > >> () > >> > >> Where the function n

Re: Long running process - how to speed up?

2022-02-20 Thread Dennis Lee Bieber
On Sun, 20 Feb 2022 18:05:33 +, Shaozhong SHI declaimed the following: >I am trying this approach, > >import multiprocessing as mp > >def my_func(x): > print(x**x) > Not much of a processing load there, especially for your small set of integers. I suspect you are consuming a signif

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Greg Ewing
On 21/02/22 6:27 am, Abdur-Rahmaan Janhangeer wrote: Well Python deliberately throws an exception if we do not pass in a function name. Just wanted to know why it should. As the above case is a 100% pure anonymous function. The syntax for a function definition is defined in the grammar as requi

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Python
Barry wrote: On 20 Feb 2022, at 15:35, Abdur-Rahmaan Janhangeer wrote: Greetings list. Out of curiosity, why doesn't Python accept def (): return '---' () Where the function name is ''? Because there is no variable that is holding a ref to the code. So it’s pointless. Fun fact, i

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Python
Abdur-Rahmaan Janhangeer wrote: Greetings list. Out of curiosity, why doesn't Python accept def (): return '---' () Where the function name is ''? For the same reason an empty sequence of characters cannot be a variable name. Do you know any language (or formal theory) that allows that?

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Christian Gollwitzer
Am 20.02.22 um 16:48 schrieb Python: Abdur-Rahmaan Janhangeer wrote: Greetings list. Out of curiosity, why doesn't Python accept def (): return '---' () Where the function name is ''? For the same reason an empty sequence of characters cannot be a variable name. Do you know any languag

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 09:38, Eryk Sun wrote: > > On 2/20/22, Abdur-Rahmaan Janhangeer wrote: > > > > Out of curiosity, why doesn't Python accept > > def (): > > return '---' > > The `def` keyword is compiled as an assignment statement, not an > expression that evaluates anonymously on the st

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Eryk Sun
On 2/20/22, Abdur-Rahmaan Janhangeer wrote: > > Out of curiosity, why doesn't Python accept > def (): > return '---' The `def` keyword is compiled as an assignment statement, not an expression that evaluates anonymously on the stack. Using `def` as an expression would require new syntax. For

Re: Long running process - how to speed up?

2022-02-20 Thread Avi Gross via Python-list
dAVId, I would like to assume that the processing needed is quite a bit more than calculating the square of each X. But as we are getting negligible information on anything useful, why continue interacting.  I am trying to imagin a scenario with a million rows of sorts in a CSV (typically not us

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Avi Gross via Python-list
Not really. Anonymous functions are anonymous in name only, so to speak. When you call a function and pass it an argument that is an anonymous function definition, it is bound to a variable within the function and used mostly in a non-anonymous way. You did not bother giving it a name but it is r

Re: Long running process - how to speed up?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 05:07, Shaozhong SHI wrote: > However, I have no idea whether this approach will be faster than > conventional approach. > > Any one has idea? Try it. Find out. The only way to know is to measure. I can't see the sleep call though. You may need to post your actual code ins

Re: Re: Long running process - how to speed up?

2022-02-20 Thread Shaozhong SHI
On Sat, 19 Feb 2022 at 18:51, Alan Gauld wrote: > On 19/02/2022 11:28, Shaozhong SHI wrote: > > > I have a cvs file of 932956 row > > That's not a lot in modern computing terms. > > > and have to have time.sleep in a Python > > script. > > Why? Is it a requirement by your customer? Your manager?

Re: Long running process - how to speed up?

2022-02-20 Thread Shaozhong SHI
On Sat, 19 Feb 2022 at 19:44, Mats Wichmann wrote: > On 2/19/22 05:09, Shaozhong SHI wrote: > > Can it be divided into several processes? > > Regards, > > David > > The answer is: "maybe". Multiprocessing doesn't happen for free, you > have to figure out how to divide the task up, requiring thou

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Dieter Maurer
Abdur-Rahmaan Janhangeer wrote at 2022-2-20 19:32 +0400: >Out of curiosity, why doesn't Python accept >def (): >return '---' > >() > >Where the function name is ''? Python knows about (somewhat restricted) anonymous functions: it calls them `lambda` expressions (the body of those functions can

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Abdur-Rahmaan Janhangeer
Yes I know about lambdas but was just an introspection about the reasoning behind ^^ Kind Regards, Abdur-Rahmaan Janhangeer about | blog github Mauritius -- https://mail.python.org/mailman/li

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Abdur-Rahmaan Janhangeer
Thanks for the answers. @Chris Well Python deliberately throws an exception if we do not pass in a function name. Just wanted to know why it should. As the above case is a 100% pure anonymous function. Kind Regards, Abdur-Rahmaan Janhangeer about | blog

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Chris Angelico
On Mon, 21 Feb 2022 at 02:33, Abdur-Rahmaan Janhangeer wrote: > > Greetings list. > > Out of curiosity, why doesn't Python This is often the wrong question. The question is more: Why should Python? Python doesn't do things just because there's no reason not to. ChrisA -- https://mail.python.or

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Dan Stromberg
On Sun, Feb 20, 2022 at 7:33 AM Abdur-Rahmaan Janhangeer < arj.pyt...@gmail.com> wrote: > Greetings list. > > Out of curiosity, why doesn't Python accept > def (): > return '---' > > () > > Where the function name is ''? > () is already an empty tuple. It would break code to change this. --

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Barry
> On 20 Feb 2022, at 15:35, Abdur-Rahmaan Janhangeer > wrote: > > Greetings list. > > Out of curiosity, why doesn't Python accept > def (): >return '---' > > () > > Where the function name is ''? Because there is no variable that is holding a ref to the code. So it’s pointless. Barr

Why does not Python accept functions with no names?

2022-02-20 Thread Abdur-Rahmaan Janhangeer
Greetings list. Out of curiosity, why doesn't Python accept def (): return '---' () Where the function name is ''? Kind Regards, Abdur-Rahmaan Janhangeer about | blog github Mauritius -