Let's try again...

On 22 Jun 2020, at 08:15, Inada Naoki <songofacandy@gmail.com> wrote:

On Mon, Jun 22, 2020 at 12:00 AM Guido van Rossum <guido@python.org> wrote:


I believe this was what Greg Stein's idea here was about. (As well as Jonathan Fine's in this thread?) But the current use of code objects makes this hard. Perhaps the code objects could have a memoryview object to hold the bytecode instead of a bytes object.


memoryview is heavy object.  Using memoryview instead of bytes object
will increase memory usage.
I think lightweight bytes-like object is better.  My rough idea is:

* New code and pyc format
 * pyc has "rodata" segment
   * It can be copied into single memory block, or can be mmapped.
     * co_code should be aligned at least 2 bytes.

Would higher alignment help? malloc is using 8 or 16 byte alignment isn't it?
Would that be better  for packing the byte code into cache lines?

* code.co_code can point to memory block in "rodata".
 * docstring, signature, and lnotab can be lazy load from "rodata".
   * signature is serialized in JSON like format.
 * Allow multiple modules in single file
   * Reduce fileno when using mmap
   * Merge more constants
 * New Python object: PyROData.
   * It is like read-only bytearray.
     * But body may be mmap-ped, instead of malloc-ed
   * code objects owns reference of PyROData.
     * When PyROData is deallocated, it munmap or free "rodata" segment.

Regards,
--
Inada Naoki  <songofacandy@gmail.com>

Barry

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VKBXY7KDI2OGESB7IPAMAIIHKR4TC7TQ/
Code of Conduct: http://python.org/psf/codeofconduct/