This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, jftuga, r.david.murray, zach.ware
Date 2017-01-17.15:29:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1484666968.19.0.201362820307.issue29285@psf.upfronthosting.co.za>
In-reply-to
Content
> they do not appear in the byte code files

It's simple to coonfirm that unassigned string literals get thrown away.:

    >>> code = compile('"doc"\n"unused"\n"us"+"ed"', '', 'exec')
    >>> code.co_consts
    ('doc', 'us', 'ed', None, 'used')
    >>> dis.dis(code)
      1           0 LOAD_CONST               0 ('doc')
                  3 STORE_NAME               0 (__doc__)

      3           6 LOAD_CONST               4 ('used')
                  9 POP_TOP
                 10 LOAD_CONST               3 (None)
                 13 RETURN_VALUE

However, they're retained up to the abstract syntax tree:

    >>> print(ast.dump(ast.parse('"doc"\n"unused"\n"us"+"ed"', '', 'exec')))
    Module(body=[
        Expr(value=Str(s='doc')),
        Expr(value=Str(s='unused')),
        Expr(value=BinOp(left=Str(s='us'),
                         op=Add(),
                         right=Str(s='ed')))])

Sans the doc string behavior, this applies to literals in general. Thus even though the compiler discards these objects, the literal still has to be parsed like any other.
History
Date User Action Args
2017-01-17 15:29:28eryksunsetrecipients: + eryksun, r.david.murray, zach.ware, jftuga
2017-01-17 15:29:28eryksunsetmessageid: <1484666968.19.0.201362820307.issue29285@psf.upfronthosting.co.za>
2017-01-17 15:29:28eryksunlinkissue29285 messages
2017-01-17 15:29:27eryksuncreate