Skip to content

The binary files produced by compiling python twice are different #93317

Closed as not planned

Description

@zhuofeng6

hi, man, i find a problem, that the binary files produced by compiling python twice are different. I was confused for a long time. The different pyc files are the following.

image

i find different places are DA and FA with Beyond Compare.

image
configparser.cpython-39.pyc

image
argparse.cpython-39.pyc

then, i see this is string instern after i study the source code of cpython, These strings are ”{“ ”{{“ ”}“ ”}“

static int
maybe_init_static_strings(void)
{
    if (!_str_open_br &&
        !(_str_open_br = PyUnicode_InternFromString("{"))) {
        return -1;
    }
    if (!_str_dbl_open_br &&
        !(_str_dbl_open_br = PyUnicode_InternFromString("{{"))) {
        return -1;
    }
    if (!_str_close_br &&
        !(_str_close_br = PyUnicode_InternFromString("}"))) {
        return -1;
    }
    if (!_str_dbl_close_br &&
        !(_str_dbl_close_br = PyUnicode_InternFromString("}}"))) {
        return -1;
    }
    if (!_str_inf &&
        !(_str_inf = PyUnicode_FromString("inf"))) {
        return -1;
    }
    if (!_str_replace_inf &&
        !(_str_replace_inf = PyUnicode_FromFormat("1e%d", 1 + DBL_MAX_10_EXP))) {
        return -1;
    }
    return 0;
}

python >3.8 compile with multithreading, so there may be different by compiling python twice. and if i add code here, it is OK! This is just my temporary plan, but i don't think this is a good idea, and i hope you could fix it

image

Activity

  1. JelleZijlstra commented on May 28, 2022

    @JelleZijlstra
    Member

    #73894 is the general issue about this.

  2. ericvsmith commented on May 28, 2022

    @ericvsmith
    Member

    Closing on favor of #73894.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions