[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Understanding MAXVARS in lparser.c
- From: Francisco Olarte <folarte@...>
- Date: Fri, 27 Oct 2023 17:16:22 +0200
Steve:
On Fri, 27 Oct 2023 at 10:57, Steve Hewson <stevehewson15@gmail.com> wrote:
> Inspired from a Reddit post, I see that the maximum number of local variables within a scope is 200 ( as defined in lparser.c ).
> Here's the snippet:
> /* maximum number of local variables per function (must be smaller than 250, due to the bytecode format) */
> #define MAXVARS 200
>
> Question-1:
> I'd like to know why the comment states 250 and the value for MAXVARS is set to 200.
Because you can set it up to 250, but do not need to set it that high.
> Question-2:
> As a layman, I'd assume the numbers to be powers of 2, like 256, but why's it 200 or 256?
Bad assumption. Probably the bytecode uses a byte for the number but
needs to reserve some values for whatever reason.
200 is probably to cap memory consumption ( in the compiler? ) or have
better alignment or something like that.
If you want to know the real details you will have to dwelve deep into the code.
Francisco Olarte.