On 2019-03-08 22:16, Martin Bammer wrote:
Hi,
what about the idea that the interpreter preallocates and preinitializes
the
tuples and dicts for function calls where possible when loading a module?
The basic premise here is wrong: function calls using the METH_FASTCALL
convention don't need t
On Fri, Mar 8, 2019 at 6:23 PM Steven D'Aprano wrote:
> A sets the argument tuple to (1, 2)
> B sets the argument tuple to (2, 3)
> B calls spam()
> A calls spam() # Oops!
I'm pretty sure the idea was to have constant tuples (1, 2) and (3, 4)
in the module instead of LOAD_CONST 1/
08.03.19 23:16, Martin Bammer пише:
what about the idea that the interpreter preallocates and preinitializes the
tuples and dicts for function calls where possible when loading a module?
Before calling a function then the interpreter would just need to update the
items which are dynamic and then
09.03.19 03:02, Greg Ewing пише:
Martin Bammer wrote:
what about the idea that the interpreter preallocates and
preinitializes the tuples and dicts for function calls where possible
when loading a module?
This would not be thread-safe. Locking would be needed around uses
of the preallocated
Ok right. There are some details which need to modify the idea:
- Thread safety:
Instead of locking the thread id could be saved in the object and then
checked when the object is used. If the thread id is wrong then a new
object must be created.
I think there is no additional locking necessary beca
Thread safety is not a problem here because of the GIL.
Am Sa., 9. März 2019 um 02:03 Uhr schrieb Greg Ewing <
greg.ew...@canterbury.ac.nz>:
> Martin Bammer wrote:
>
> > what about the idea that the interpreter preallocates and preinitializes
> > the tuples and dicts for function calls where poss
On Fri, Mar 08, 2019 at 10:16:02PM +0100, Martin Bammer wrote:
> Hi,
>
> what about the idea that the interpreter preallocates and
> preinitializes the tuples and dicts for function calls where possible
> when loading a module?
That's an implementation detail. CPython may or may not use tuples
Martin Bammer wrote:
what about the idea that the interpreter preallocates and preinitializes
the tuples and dicts for function calls where possible when loading a module?
This would not be thread-safe. Locking would be needed around uses
of the preallocated objects, and that might take away s
Hi,
what about the idea that the interpreter preallocates and preinitializes
the
tuples and dicts for function calls where possible when loading a module?
Before calling a function then the interpreter would just need to update
the
items which are dynamic and then call the function.
Some exa