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.

作者 vstinner
收信人 vstinner
日期 2012-03-22.01:35:20
SpamBayes Score 3.7930387e-10
Marked as misclassified
Message-id <1332380135.46.0.264363154256.issue14385@psf.upfronthosting.co.za>
In-reply-to
内容
CPython expects __builtins__ to be a dict, but it is interesting to be able to use another type. For example, my pysandbox project (sandbox to secure Python) requires a read-only mapping for __builtins__.

The PEP 416 was rejected, so there is no builtin frozendict type, but it looks like the dictproxy type will be exposed as a public type.

Attached patch uses PyDict_CheckExact() to check if __builtins__ is a dict and add a "slow-path" for other types. The overhead on runtime performance should be very low (near zero), PyDict_CheckExact() just dereference a pointer (to read the object type) and compare two pointers.

The patch depends on issue #14383 patch (identifier.patch) for the __build_class__ identifier. I can write a new patch without this dependency if needed.
历史
日期 用户 动作 参数
2012-03-22 01:35:38vstinner修改recipients: + vstinner
2012-03-22 01:35:35vstinner修改messageid: <1332380135.46.0.264363154256.issue14385@psf.upfronthosting.co.za>
2012-03-22 01:35:33vstinner链接issue14385 messages
2012-03-22 01:35:32vstinner创建