Skip to content
  • Damien George's avatar
    py: Create str/bytes objects in the parser, not the compiler. · 5255255f
    Damien George authored
    Previous to this patch any non-interned str/bytes objects would create a
    special parse node that held a copy of the str/bytes data.  Then in the
    compiler this data would be turned into a str/bytes object.  This actually
    lead to 2 copies of the data, one in the parse node and one in the object.
    The parse node's copy of the data would be freed at the end of the compile
    stage but nevertheless it meant that the peak memory usage of the
    parse/compile stage was higher than it needed to be (by an amount equal to
    the number of bytes in all the non-interned str/bytes objects).
    
    This patch changes the behaviour so that str/bytes objects are created
    directly in the parser and the object stored in a const-object parse node
    (which already exists for bignum, float and complex const objects).  This
    reduces peak RAM usage of the parse/compile stage, simplifies the parser
    and compiler, and reduces code size by about 170 bytes on Thumb2 archs,
    and by about 300 bytes on Xtensa archs.
    5255255f