Rationale for read-only property of co_code

castironpi at gmail.com castironpi at gmail.com
Wed Apr 2 11:35:32 EDT 2008


On Apr 2, 5:00 am, João Neves <seve... at gmail.com> wrote:
> Hello all,
>
> I've got this question that has been nagging me for a few days now.
> What are the reasons for us to have co_code as read-only? I've been
> trying to get some info about it, but I kept hitting the wall.
>
> Correct me if I'm wrong, but as far as I understand, co_code
> represents the compiled bytecode that should be run when, for
> instance, a function is called. Wouldn't it be beneficial for
> programmers to be able to change the bytecode in runtime? I mean, one
> can't, as far as I'm aware, change the bytecode by accident, so if the
> programmer would wish to change a function at runtime, he could do so
> at his own risk.
>
> If there is a higher reason behind the read-only property of co_code,
> I definitely fail to see it, and would like to know what it is. If
> not, why aren't we allowed to write into it?
>
> Thanks in advance,
>
> João Neves

Are Python bytes codes Python byte codes?  Do you foresee any machine-
dependent optimizations?



More information about the Python-list mailing list