Repository navigation
remove *_INTERNED opcodes from marshal #75558
Description
Activity
The *_INTERN opcodes inform the marsahl reader to intern the encoded string after deserialization. I believe for pycs this is pointless because PyCode_New ends up interning all strings that are interesting to intern. Writing this opcodes makes pycs non-deterministic because the intern state may be inconsistent in the writer. See https://bugzilla.opensuse.org/show_bug.cgi?id=1049186
- added3.7 (EOL)end of lifeend of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement
on Sep 7, 2017 Marshal is used not only in pyc files. It is used for fast data serialization, faster than pickle, json, etc.
Used but not really supported. Anyway, I doubt intern round-tripping is a particularly important.
Reacted by Gregory P. Smithw_ref() depends on refcnt already.
I don't think removing *_INTERN opcode makes PYC reproducible.
Lines 269 to 271 in 1f06a68
/* if it has only one reference, it definitely isn't shared */ if (Py_REFCNT(v) == 1) return 0; I think "intern one string, then share it 10 times" is faster than
"share one string 10 times, then intern each of 10 references".On Thu, Sep 7, 2017, at 01:17, INADA Naoki wrote:
INADA Naoki added the comment:
w_ref() depends on refcnt already.
I don't think removing *_INTERN opcode makes PYC reproducible.
Lines 269 to 271 in 1f06a68
/* if it has only one reference, it definitely isn't shared */ if (Py_REFCNT(v) == 1) return 0; I know—we're going to have to do something about that, too. In practice,
though, the interning behavior seems to be a bigger reproducibility
problem.I think "intern one string, then share it 10 times" is faster than
"share one string 10 times, then intern each of 10 references".We end up interning each reference individually currently.
We end up interning each reference individually currently.
But interning interned string is much faster. It only checks flag.
Interning normal string requires dict lookup.On Thu, Sep 7, 2017, at 09:46, INADA Naoki wrote:
INADA Naoki added the comment:
> We end up interning each reference individually currently.
But interning interned string is much faster. It only checks flag.
Interning normal string requires dict lookup.We could makes sure the version in the internal marshal memo is interned
if appropriate.I doubt that interning cause reproduciblity problem.
AFAIK, all strings in code object are interned or not
interned deterministically.https://bugzilla.opensuse.org/show_bug.cgi?id=1049186
This issue seems be caused by w_ref() based on object refcnt,
not interning.Interning does cause reproducibility problems - #129724
When I made that comment in 2018, the free-threaded build did not exist, and only Unicode strings could be interned.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: