On 4/8/24 3:36 PM, Paul Eggert wrote:
> For what it's worth, the business about the cost of x.append(y) (it's
> O(len(x)), and O(1) amortized) has been a standard part of the cost model
> lecture in my programming languages course for more than two decades, so I
> hope that UCLA graduates, at le
On 4/8/24 14:19, Bruno Haible wrote:
My experience is that ChatGPT (3.5) provides good answers for things that
have a lot of mentions on the web. Whereas for things that are rarely
mentioned, it starts to hallucinate and often provides wrong answers.
Therefore, for routine questions around Python
Hi Collin,
> > - It explains ChatGPT's failure: Probably there are more explanations
> > regarding += on strings, on the web, than regarding += on lists.
> > So ChatGPT used the "common" explanation, for strings, and then
> > substituted s/string/list/.
>
> Interesting. I know very
On 4/8/24 7:23 AM, Bruno Haible wrote:
> - It explains ChatGPT's failure: Probably there are more explanations
> regarding += on strings, on the web, than regarding += on lists.
> So ChatGPT used the "common" explanation, for strings, and then
> substituted s/string/list/.
Interestin
Hi Collin,
> I think that I see the issue here. I believe this is a case of the
> "prior knowledge summarization engine" being incorrect. Given this
> statement:
>
> a += [var]
>
> it seems to think that a new copy of 'a' is being created. This is
> incorrect. The given statement is equal to
Hi Paul,
On 4/7/24 5:51 PM, Paul Eggert wrote:
> a.append should be faster, as it need not cons the singleton.
Thanks. Yes, that it is what I was trying to get at. But I didn't know
the correct wording. :)
Here is 'var.extend(["a"])' added to the simple timeit comparison:
>>> import timeit
>>>
On 2024-04-07 16:07, Collin Funk wrote:
I think
that the difference between 'a.extend([var])' and 'a.append(var)'
would better explain the differences in timing that we see with a
large number of repetitions.
a.append should be faster, as it need not cons the singleton.
Hi Bruno,
On 4/7/24 7:23 AM, Bruno Haible wrote:
> I like the first one a little more. So I asked the prior knowledge
> summarization engine (ChatGPT):
I like that description, "prior knowledge summarization engine".
> Since you show me how to do benchmarks, and since ChatGPT warns about large
>
Collin Funk wrote:
> That reminds me, is there a reason why in many places there is
> something like this:
>
> newtail = []
> for item in tail:
> newtail += [item]
>
> instead of this?
>
> newtail = []
> for item in tail:
> newtail.append(item)
>
> I like t