Re: frozendict: an experiment
On Sat, Jul 18, 2020 at 7:05 AM Marco Sulla wrote: > > > > > But when frozendicts are merged? > > I think there is a very little chance. > > frozendicts could be used for kwargs: > > f(a=1, b=2) > # some code > f(a=1, b=2) > > For what I know, CPython uses PyDictObject for kwargs. Since dicts are > mutable, it's a problem to cache them properly. > On caller side, Python doesn't use dict at all. On callee side, dict is used for `**kwargs`. But changing it to frozendict is backward incompatible change. > On Fri, 17 Jul 2020 at 04:13, Inada Naoki wrote: > > I'm OK to all combined dict for frozen dict. But I think key-sharing is > > still > > interesting optimization for frozen dict. And supporting key-sharing dict > > is much easier for frozendict than for mutable dict. > > Yes, I think the same. > > On Fri, 17 Jul 2020 at 04:13, Inada Naoki wrote: > > Then, there is no reason to not support the view for frozendict? > > I didn't say to not support views... I said that "real objects", that > implement the dictview API, could be returned by frozendict.keys() > etc. It will cause performance penalty. Currently, `for k,v in d.items()` doesn't create temporary list or set-like. I think using "real object" is not good performance optimization. Regards, -- Inada Naoki -- https://mail.python.org/mailman/listinfo/python-list
Re: Python pandas Excel
J Conrado wrote: > > > > > > > > > > > > HI, > > > I have an excel file with several columns, the first day/month,/year and > hour: > > > Data > 01/11/2017 00:00 > 01/11/2017 03:00 > 01/11/2017 06:00 > 01/11/2017 09:00 > 01/11/2017 12:00 > 01/11/2017 15:00 > 01/11/2017 18:00 > 01/11/2017 21:00 > 02/11/2017 00:00 > 02/11/2017 03:00 > 02/11/2017 06:00 > 02/11/2017 09:00 > 02/11/2017 12:00 > 02/11/2017 15:00 > 02/11/2017 18:00 > 02/11/2017 21:00 > 03/11/2017 00:00 > 03/11/2017 03:00 > 03/11/2017 06:00 > 03/11/2017 09:00 > 03/11/2017 12:00 > 03/11/2017 15:00 > 03/11/2017 18:00 > 03/11/2017 21:00 > 04/11/2017 00:00 > 04/11/2017 03:00 > 04/11/2017 06:00 > 04/11/2017 09:00 > 04/11/2017 12:00 > 04/11/2017 15:00 > 04/11/2017 18:00 > 04/11/2017 21:00 > 05/11/2017 00:00 > 05/11/2017 03:00 > 05/11/2017 06:00 > 05/11/2017 09:00 > 05/11/2017 12:00 > 05/11/2017 15:00 > 05/11/2017 18:00 > 05/11/2017 21:00 > 06/11/2017 00:00 > 06/11/2017 03:00 > 06/11/2017 06:00 > 06/11/2017 09:00 > 06/11/2017 12:00 > 06/11/2017 15:00 > 06/11/2017 18:00 > 06/11/2017 21:00 > 07/11/2017 00:00 > 07/11/2017 03:00 > 07/11/2017 06:00 > 07/11/2017 09:00 > 07/11/2017 12:00 > 07/11/2017 15:00 > 07/11/2017 18:00 > 07/11/2017 21:00 > 08/11/2017 00:00 > 08/11/2017 03:00 > 08/11/2017 06:00 > 08/11/2017 09:00 > 08/11/2017 12:00 > 08/11/2017 15:00 > 08/11/2017 21:00 > 09/11/2017 00:00 > 09/11/2017 03:00 > 09/11/2017 06:00 > 09/11/2017 09:00 > 09/11/2017 12:00 > 09/11/2017 15:00 > 09/11/2017 18:00 > 09/11/2017 21:00 > 10/11/2017 00:00 > 10/11/2017 03:00 > 10/11/2017 06:00 > 10/11/2017 09:00 > 10/11/2017 12:00 > 10/11/2017 15:00 > 10/11/2017 18:00 > 10/11/2017 21:00 > 11/11/2017 00:00 > 11/11/2017 03:00 > 11/11/2017 06:00 > 11/11/2017 09:00 > 11/11/2017 12:00 > 11/11/2017 15:00 > 11/11/2017 18:00 > 11/11/2017 21:00 > 12/11/2017 00:00 > 12/11/2017 03:00 > 12/11/2017 06:00 > 12/11/2017 09:00 > 12/11/2017 12:00 > 12/11/2017 15:00 > 12/11/2017 18:00 > 12/11/2017 21:00 > 13/11/2017 00:00 > 13/11/2017 03:00 > 13/11/2017 06:00 > 13/11/2017 09:00 > 13/11/2017 12:00 > 13/11/2017 15:00 > 13/11/2017 18:00 > 13/11/2017 21:00 > 14/11/2017 00:00 > 14/11/2017 03:00 > 14/11/2017 06:00 > 14/11/2017 09:00 > 14/11/2017 12:00 > 14/11/2017 15:00 > 14/11/2017 18:00 > 14/11/2017 21:00 > 15/11/2017 00:00 > 15/11/2017 03:00 > 15/11/2017 06:00 > 15/11/2017 09:00 > 15/11/2017 12:00 > 15/11/2017 15:00 > 15/11/2017 18:00 > 15/11/2017 21:00 > 16/11/2017 00:00 > 16/11/2017 03:00 > 16/11/2017 06:00 > 16/11/2017 09:00 > 16/11/2017 12:00 > 16/11/2017 15:00 > 16/11/2017 18:00 > 16/11/2017 21:00 > 17/11/2017 00:00 > 17/11/2017 03:00 > 17/11/2017 06:00 > 17/11/2017 09:00 > 17/11/2017 12:00 > 17/11/2017 15:00 > 17/11/2017 18:00 > 18/11/2017 00:00 > 18/11/2017 03:00 > 18/11/2017 06:00 > 18/11/2017 09:00 > 18/11/2017 12:00 > 18/11/2017 15:00 > 18/11/2017 18:00 > 18/11/2017 21:00 > 19/11/2017 00:00 > 19/11/2017 03:00 > 19/11/2017 06:00 > 19/11/2017 09:00 > 19/11/2017 12:00 > 19/11/2017 15:00 > 19/11/2017 18:00 > 19/11/2017 21:00 > 20/11/2017 00:00 > 20/11/2017 03:00 > 20/11/2017 06:00 > 20/11/2017 09:00 > 20/11/2017 12:00 > 20/11/2017 15:00 > 20/11/2017 18:00 > 20/11/2017 21:00 > 21/11/2017 00:00 > 21/11/2017 03:00 > 21/11/2017 06:00 > 21/11/2017 09:00 > 21/11/2017 12:00 > 21/11/2017 15:00 > 21/11/2017 18:00 > 22/11/2017 03:00 > 22/11/2017 06:00 > 22/11/2017 09:00 > 22/11/2017 12:00 > 22/11/2017 15:00 > 22/11/2017 18:00 > 22/11/2017 21:00 > 23/11/2017 00:00 > 23/11/2017 03:00 > 23/11/2017 06:00 > 23/11/2017 09:00 > 23/11/2017 12:00 > 23/11/2017 15:00 > 23/11/2017 18:00 > 23/11/2017 21:00 > 24/11/2017 00:00 > 24/11/2017 03:00 > 24/11/2017 06:00 > 24/11/2017 09:00 > 24/11/2017 12:00 > 24/11/2017 15:00 > 24/11/2017 18:00 > 24/11/2017 21:00 > 25/11/2017 00:00 > 25/11/2017 03:00 > 25/11/2017 06:00 > 25/11/2017 09:00 > 25/11/2017 12:00 > 25/11/2017 15:00 > 25/11/2017 18:00 > 25/11/2017 21:00 > 26/11/2017 00:00 > 26/11/2017 03:00 > 26/11/2017 06:00 > 26/11/2017 09:00 > 26/11/2017 12:00 > 26/11/2017 15:00 > 26/11/2017 18:00 > 26/11/2017 21:00 > 27/11/2017 03:00 > 27/11/2017 06:00 > 27/11/2017 09:00 > 27/11/2017 12:00 > 27/11/2017 15:00 > 27/11/2017 18:00 > 27/11/2017 21:00 > 28/11/2017 06:00 > 28/11/2017 09:00 > 28/11/2017 12:00 > 28/11/2017 15:00 > 28/11/2017 18:00 > 28/11/2017 21:00 > 29/11/2017 00:00 > 29/11/2017 03:00 > 29/11/2017 06:00 > 29/11/2017 09:00 > 29/11/2017 12:00 > 29/11/2017 15:00 > 29/11/2017 18:00 > 29/11/2017 21:00 > 30/11/2017 00:00 > 30/11/2017 03:00 > 30/11/2017 06:00 > 30/11/2017 09:00 > 30/11/2017 12:00 > 30/11/2017 15:00 > 30/11/2017 18:00 > 30/11/2017 21:00 > > > This is the value tha a have using pandas: > > > print(data) > > > 0 2017-01-11 00:00:00 > 1 2017-01-11 03:00:00 > 2 2017-01-11 06:00:00 > 3 2017-01-11 09:00:00 > 4 2017-01-11 12:00:00 > ... > 228 2017-11-30 09:00:00 > 229 2017-11-30 12:00:00 > 230 2017-11-30 15:00:00 > 231 2017-11-30 18:00:00 > 232 2017-11-30 21:00:00 > > Please, how can I get four arrays for day, m
Re: A Python installation help doc much more friendly to newcomers? [Was Re: help]
On Sat, 18 Jul 2020 at 05:39, dn via Python-list wrote: > > On 18/07/20 3:29 PM, boB Stepp wrote: > > On Fri, Jul 17, 2020 at 9:48 PM dn via Python-list > > wrote: > >> > >> On 18/07/20 1:53 PM, Castillo, Herbert S wrote: > >>> I downloaded python not to long ago, and today when I opened Python on > >>> Windows it gave me a modify setup prompt. I have tried to click on modify > >>> , repair and even uninstalled and installed it back, but when I try to > >>> open Python up again, I keep on getting the same modify setup prompt. I > >>> am not sure of what to do? Thank you in advance. > >> > >> > >> Regret that this mailing list does not support graphics attachments. > >> > >> Which part of https://docs.python.org/dev/using/windows.html failed? > > > > Just for grins I just now glanced at the link dn provided. Yes, this > > is a very thorough, very accurate, very *technical* help resource. > > But if I were a person who had never seen a shell, cmd.exe or > > Powershell window, never programmed before, had no clue about how to > > truly use my OS, etc., I don't think I would understand a bit of this > > "help" document, and, at best, would find it very intimidating. If > > this community does wish to cater to those who are totally new to the > > world of programming and learning how to really use their PC at any > > depth, then I think a different approach or set of documents is > > needed. And an easier way for those playing with the idea of learning > > programming and Python to connect with such documentation. > > [snip] > > There is also THE Python Tutorial - the opening action is two?three > pages 'in'. Is that suitably less-technical and more usable to a 'beginner'? > https://docs.python.org/3/tutorial/index.html I would say that the official tutorial is not targeted at the total novice. I think it used to be described as the tutorial for people with experience of programming in other languages but I might be misremembering. The main python.org page links to a "beginners guide" well actually there are two beginners guides... https://www.python.org/ Under "get started" there is a link to this beginners guide: https://www.python.org/about/gettingstarted/ You can also hover over documentation and choose beginners guide to get this one: https://wiki.python.org/moin/BeginnersGuide The former starts by asking whether you are new to programming and if so suggests this page: https://wiki.python.org/moin/BeginnersGuide/NonProgrammers It also has an "installing" section which links to here: https://wiki.python.org/moin/BeginnersGuide/Download All of these have lots of information and many links to other pages. I'm not sure how you'd find the page dn linked to which is at least more direct about how to install: https://docs.python.org/dev/using/windows.html Certainly I don't see it if I go straight to the download pages: https://www.python.org/downloads/ https://www.python.org/downloads/windows/ I think if I was new to programming or installing software in general I would find all of this quite bewildering. My experience of teaching total novice programmers is that you really can't shirk the fundamental question: how should I install this thing and start using it *before* I have any idea what I'm doing? Novices don't need to be told that there are 100 ways to do it: they need to be told exactly how to do it in a way that will work for them. If I was writing the tutorial but aiming at total novices I would probably begin by suggesting to use an online shell: https://www.python.org/shell/ There could be a short guide there that explains very clearly how to do simple commands in that online shell. At that point you are ready to test the examples from page 3 of the official tutorial but I think it is still not pitched at novices: https://docs.python.org/3/tutorial/introduction.html Then after a few examples and some familiarity it could be time to suggest installing locally. That should be with a no nonsense explanation that makes no reference to terminals, PATH, etc because those are just intimidating distractions to a novice at that point in time. The sympy docs have a lot of room for improvement but one of the things that is very useful for beginners there is the "Run code block in sympy live" button which means that you can follow the tutorial/docs and try things out before having anything installed locally: https://docs.sympy.org/latest/tutorial/intro.html#introduction -- Oscar -- https://mail.python.org/mailman/listinfo/python-list
Re: Fake news Detect
Data Sceptic has a couple podcast and some of the code is open source. https://dataskeptic.com/blog/episodes/2018/algorithmic-detection-of-fake-news Thanks Vincent Davis 720-301-3003 *Want to get a hold of me?* *SMS: awesome.phone: ok...* *email: bad!* On Fri, Jul 17, 2020 at 11:39 PM Mike Dewhirst wrote: > On 18/07/2020 6:16 am, Grant Edwards wrote: > > On 2020-07-17, Dennis Lee Bieber wrote: > >> On Fri, 17 Jul 2020 16:02:15 - (UTC), Gazu > declaimed > >> the following: > >> > >>> Hey Guys I am new to python and i am building a fake news detection > >>> system ... > >> I suspect that, if anyone had done this already, it would likely be > >> found on some source code archive (github?) -- and you'd just be > >> duplicating the effort. > >> > >> Essentially, since the core of this functionality depends upon the > >> algorithm, YOU will have to develop the algorithm. > > Or he could do something easier like eliminating hunger, war and > > Covid-19. > > Or like changing culture to give more weight to education, integrity > etc. We need systems to automatically identify fake news and educate > believers. News consumers have to do it. > > News consumers need a system where they can go to check news items to > see if they are credible. Without the cooperation of news conduits - to > label news items with the source - that will be difficult. > > However, that doesn't mean the crowd can't check credibility. So, > culture change is needed. No-one wants to be outed as a fake news source. > > Here's a project. Build an automatic news aggregation site which > collects all news in two pages per news item. Page 1 for the item and > page 2 for the crowd credibility assessment and naming of the apparent > source. Should work somewhat like Wikipedia. Except editors for page 2 > would need a threshold score for being correct. Everyone can criticise > but you lose points for being on the wrong side of history. > > That'll be 2 cents > > Mike > > > > > -- > > Grant > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
RE: help
Thank you, boB! Yes, I kept on opening the installer. Your directions were great from memory, and I will look into the Python tutor mailing list. Thanks again. Herbert -Original Message- From: boB Stepp Sent: Friday, July 17, 2020 7:43 PM To: Castillo, Herbert S Cc: python-list@python.org Subject: Re: help On Fri, Jul 17, 2020 at 9:00 PM Castillo, Herbert S wrote: > I downloaded python not to long ago, and today when I opened Python on > Windows it gave me a modify setup prompt. I have tried to click on modify , > repair and even uninstalled and installed it back, but when I try to open > Python up again, I keep on getting the same modify setup prompt. I am not > sure of what to do? Thank you in advance. It sounds like you are just rerunning the python installer. Instead, open a command prompt or Powershell and type "py". That will bring up the Python interactive environment where you can type Python commands. Or, probably better, open IDLE -- the provided Python editing environment -- by pressing your Windows key which brings up the list of available programs/program folders, find Python, expand that if needed by clicking on it and then clicking on "IDLE". That will bring up the Python interactive prompt as well. You can also create a new Python file using the provided "File" menu, etc. BTW, I am doing this from memory. I don't have a Windows PC handy, but hopefully it is enough to get you over the hump. BTW, there is a Python Tutor mailing list designed for those learning Python. Also, the main Python website has documentation, lists of resources, tutorial, etc., to also help jumpstart your learning. Have fun! HTH! -- boB -- https://mail.python.org/mailman/listinfo/python-list
Iterating over dict is slower than iterating over iter(dict)?
I noticed that iterating over a dictionary seems quite slower than creating an iterator and iterating over it. Maybe I miss something? marco@buzz:~/sources/cpython$ ./python dict_bench.py Name: `for x in dict`; Size:8; Time: 1.091e-07 Name: `for x in dict`; Size: 1000; Time: 1.008e-05 Name: `for x in iter(dict)`;Size:8; Time: 1.845e-08 Name: `for x in iter(dict)`;Size: 1000; Time: 1.844e-08 Name: `iter(dict)`; Size:8; Time: 5.260e-08 Name: `iter(dict)`; Size: 1000; Time: 5.262e-08 Environment: marco@buzz:~/sources/cpython$ ./python -VV Python 3.10.0a0 (heads/master:64053c31a4, Jul 18 2020, 20:14:48) [GCC 10.1.1 20200718] dict_bench.py: import timeit from string import Template def autorange(stmt, setup="pass", repeat=5): if setup == None: setup = "pass" t = timeit.Timer(stmt=stmt, setup=setup) a = t.autorange() number = a[0] return min(*t.repeat(number=number, repeat=repeat), a[1]) / number dict_sizes = (8, 1000) benchmarks = ( {"name": "for x in dict", "stmt": "for x in it: pass", "setup": """ o = {k:k for k in range($size)} it = o """}, {"name": "for x in iter(dict)", "stmt": "for x in it: pass", "setup": """ o = {k:k for k in range($size)} it = iter(o) """}, {"name": "iter(dict)", "stmt": "iter(o)", "setup": """ o = {k:k for k in range($size)} """}, ) for benchmark in benchmarks: for dict_size in dict_sizes: setup_tpl = benchmark.get("setup") if setup_tpl == None: setup = setup_tpl else: setup = Template(setup_tpl).substitute(size=dict_size) print("Name: {: <25} Size: {: >4}; Time: {:.3e}".format( "`{}`;".format(benchmark["name"]), dict_size, autorange(stmt=benchmark["stmt"], setup=setup) )) -- https://mail.python.org/mailman/listinfo/python-list
Re: Iterating over dict is slower than iterating over iter(dict)?
On Sun, Jul 19, 2020 at 7:20 AM Marco Sulla wrote: > > I noticed that iterating over a dictionary seems quite slower than creating > an iterator and iterating over it. Maybe I miss something? Welcome to microbenchmarks, where the tiniest change suddenly makes the entire benchmark meaningless :) > benchmarks = ( > {"name": "for x in dict", "stmt": "for x in it: pass", "setup": """ > o = {k:k for k in range($size)} > it = o > """}, > {"name": "for x in iter(dict)", "stmt": "for x in it: pass", "setup": > """ > o = {k:k for k in range($size)} > it = iter(o) > """}, > {"name": "iter(dict)", "stmt": "iter(o)", "setup": """ > o = {k:k for k in range($size)} > """}, > ) You're creating an iterator once and then iterating over it lots of times. In other words, after the first timing test, all the rest are iterating over an empty collection. Unsurprisingly, that's faster than actually looping :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: frozendict: an experiment
On Sat, 18 Jul 2020 at 10:02, Inada Naoki wrote: > On Sat, Jul 18, 2020 at 7:05 AM Marco Sulla > wrote: > > For what I know, CPython uses PyDictObject for kwargs. Since dicts are > > mutable, it's a problem to cache them properly. > > On caller side, Python doesn't use dict at all. > On callee side, dict is used for `**kwargs`. But changing it to > frozendict is > backward incompatible change. > Not sure of what you mean with caller and callee. If you're talking about Python, I agree, kwargs must be dicts. But I was talking about CPython and PyDictObject, that is used internally for kwargs. On Sat, 18 Jul 2020 at 10:02, Inada Naoki wrote: > Currently, `for k,v in d.items()` > doesn't create > temporary list or set-like. > I think using "real object" is not good performance optimization. > Well, this is true... but they create view objects that are quite slow. -- https://mail.python.org/mailman/listinfo/python-list
Re: Iterating over dict is slower than iterating over iter(dict)?
... oh my ... Sure, thank you. Thinking positive, I wasted a lot of hours, but I discovered timeit.Timer.autorange On Sat, 18 Jul 2020 at 23:30, Chris Angelico wrote: > On Sun, Jul 19, 2020 at 7:20 AM Marco Sulla > wrote: > > > > I noticed that iterating over a dictionary seems quite slower than > creating > > an iterator and iterating over it. Maybe I miss something? > > Welcome to microbenchmarks, where the tiniest change suddenly makes > the entire benchmark meaningless :) > > > benchmarks = ( > > {"name": "for x in dict", "stmt": "for x in it: pass", "setup": """ > > o = {k:k for k in range($size)} > > it = o > > """}, > > {"name": "for x in iter(dict)", "stmt": "for x in it: pass", "setup": > > """ > > o = {k:k for k in range($size)} > > it = iter(o) > > """}, > > {"name": "iter(dict)", "stmt": "iter(o)", "setup": """ > > o = {k:k for k in range($size)} > > """}, > > ) > > You're creating an iterator once and then iterating over it lots of > times. In other words, after the first timing test, all the rest are > iterating over an empty collection. Unsurprisingly, that's faster than > actually looping :) > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Iterating over dict is slower than iterating over iter(dict)?
On Sun, Jul 19, 2020 at 8:56 AM Marco Sulla wrote: > > ... oh my ... Sure, thank you. > Thinking positive, I wasted a lot of hours, but I discovered > timeit.Timer.autorange > Nah... You *spent* a lot of hours, almost certainly enjoyably, and along the way, you learned things! That's not wasted time! :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: A Python installation help doc much more friendly to newcomers? [Was Re: help]
On 18/07/20 11:48 PM, Oscar Benjamin wrote: On Sat, 18 Jul 2020 at 05:39, dn via Python-list wrote: On 18/07/20 3:29 PM, boB Stepp wrote: On Fri, Jul 17, 2020 at 9:48 PM dn via Python-list wrote: On 18/07/20 1:53 PM, Castillo, Herbert S wrote: I downloaded python not to long ago, and today when I opened Python on Windows it gave me a modify setup prompt. I have tried to click on modify , repair and even uninstalled and installed it back, but when I try to open Python up again, I keep on getting the same modify setup prompt. I am not sure of what to do? Thank you in advance. Just for grins I just now glanced at the link dn provided. Yes, this is a very thorough, very accurate, very *technical* help resource. But if I were a person who had never seen a shell, cmd.exe or Powershell window, never programmed before, had no clue about how to truly use my OS, etc., I don't think I would understand a bit of this "help" document, and, at best, would find it very intimidating. If this community does wish to cater to those who are totally new to the world of programming and learning how to really use their PC at any depth, then I think a different approach or set of documents is needed. And an easier way for those playing with the idea of learning programming and Python to connect with such documentation. [snip] There is also THE Python Tutorial - the opening action is two?three pages 'in'. Is that suitably less-technical and more usable to a 'beginner'? https://docs.python.org/3/tutorial/index.html I would say that the official tutorial is not targeted at the total novice. I think it used to be described as the tutorial for people with experience of programming in other languages but I might be misremembering. The main python.org page links to a "beginners guide" well actually there are two beginners guides... https://www.python.org/ ... Certainly I don't see it if I go straight to the download pages: https://www.python.org/downloads/ https://www.python.org/downloads/windows/ I think if I was new to programming or installing software in general I would find all of this quite bewildering. My experience of teaching total novice programmers is that you really can't shirk the fundamental question: how should I install this thing and start using it *before* I have any idea what I'm doing? Novices don't need to be told that there are 100 ways to do it: they need to be told exactly how to do it in a way that will work for them. ... +1, well written! For grins (as boB would say) I scanned Oracle's intro pages to Java programming (JDK), and they have a logical progression from installation instructions to "proving" the installation with the ubiquitous Hello-World first-program. Whereas the MySQL web site requires one to select the appropriate download and then remember (!) to keep reading. Whereupon the manual offers advice about testing the server, etc. Whereas those are decades old and well-established, in case of comparison the 'younger' MongoDB's documentation was more complicated. The installation of the server was not followed by a link to information about running the client, to be able to assure the system and understand the most basic (debugging?) linkage. None of these are suited to the 'smart phone' world, where software is selected from an 'app store' and once installed, 'it just works'. Is that where these neophyte users' troubles start - a disconnect between such expectations and the Python reality? (it's all very alien to my Linux world/memories of MS-Win .msi files with a check-box at the end which invited a start-up or display of suitable help files) Yes, the observation that we have folk who are quite probably downloading a command-line program(me) for the first time in their lives, but is that a valid excuse? What I've run out of time to compare-and-contrast is the advantage of pointing users at a Python-environment distribution, eg Anaconda. If 'we' are less interested in caring for beginners and their basic needs, should we point them at others who are? Observations (further to/underlining @Oscar's points): - the requirements of a beginner installing for the first time (and maybe his/her first programming language) are totally different to someone wanting to install a new version of Python or on a new machine. (ie done-it-all-before/want it to be quick-and-easy/don't bother me with loads of docs) - most docs seem to try to be 'all things to all people', whereas the differences between platforms inevitably make the writing complicated and the reading difficult to follow. Thus, consider separating entries by OpSys and/or installation method. - a reference manual is not 'the place' for beginners, who require a more tutorial/hand-holding approach - a beginners' installation tutorial should include a first program(me) and thus run through the command-line/editor/execute/REPL etc philosophies. This may be opening yet another
Re: frozendict: an experiment
On Sun, Jul 19, 2020 at 6:38 AM Marco Sulla wrote: > > On Sat, 18 Jul 2020 at 10:02, Inada Naoki wrote: >> >> On Sat, Jul 18, 2020 at 7:05 AM Marco Sulla >> wrote: >> > For what I know, CPython uses PyDictObject for kwargs. Since dicts are >> > mutable, it's a problem to cache them properly. >> >> On caller side, Python doesn't use dict at all. >> On callee side, dict is used for `**kwargs`. But changing it to frozendict >> is >> backward incompatible change. > > > Not sure of what you mean with caller and callee. If you're talking about > Python, I agree, kwargs must be dicts. But I was talking about CPython and > PyDictObject, that is used internally for kwargs. > I am talking about CPython VM. Caller is code calling Python. Callee is the function called. Look at the caller side first: # x.py foo(a=1, b=2) $ python3 -m dis x.py 1 0 LOAD_NAME0 (foo) 2 LOAD_CONST 0 (1) 4 LOAD_CONST 1 (2) 6 LOAD_CONST 2 (('a', 'b')) 8 CALL_FUNCTION_KW 2 10 POP_TOP 12 LOAD_CONST 3 (None) 14 RETURN_VALUE As you can see, dict is not created during calling a function. On the other hand, if callee is defined as: def foo(a, b): ... CPython VM doesn't create a dict at all. If callee is defined as: def foo(**kwargs): ... The kwargs is dict, of course. And changing it to frozendict is not backward compatible. C function is similar. If the C function is defined using METH_KEYWORDS, keyword arguments are passed as dict. If the C function is defined using METH_FASTCALL, keyword arguments are passed as C array. > On Sat, 18 Jul 2020 at 10:02, Inada Naoki wrote: >> >> Currently, `for k,v in d.items()` >> doesn't create >> temporary list or set-like. >> I think using "real object" is not good performance optimization. > > > Well, this is true... but they create view objects that are quite slow. Is it really slow? It is just a thin wrapper object. How is it slow compared iter(list)? Iterator is just a thin wrapper too. Regards, -- Inada Naoki -- https://mail.python.org/mailman/listinfo/python-list