python中的猴子补丁Monkey Patch

猴子补丁是指在运行时动态修改类、模块或功能的代码,以解决第三方代码的问题或添加新功能。其名称源于早期的'guerrilla patch',因发音接近而转为'monkey patch'。在Python中,可以通过猴子补丁实现不改变原代码而修改标准库的行为,如gevent通过`monkey.patch_all()`将阻塞调用转换为协作式运行。然而,使用猴子补丁也可能导致版本更新时的破坏、补丁冲突和理解困扰。
摘要由CSDN通过智能技术生成

什么是猴子补丁
the term monkey patch only refers to dynamic modifications of a class or module at runtime, motivated by the intent to patch existing third-party code as a workaround to a bug or feature which does not act as desired

即在运行时对方法 / 类 / 属性 / 功能进行修改,把新的代码作为解决方案代替原有的程序,也就是为其打上补丁。

为什么叫做猴子补丁
The term monkey patch seems to have come from an earlier term, guerrilla patch, which referred to changing code sneakily – and possibly incompatibly with other such patches – at runtime.The word guerrilla, homophonous with gorilla (or nearly so), became monkey, possibly to make the patch sound less intimidating.[1] An alternative etymology is that it refers to “monkeying about” with the code (messing with it).

一种说法杂牌军、游击队的英文发音与猩猩相似,杂牌军、游击队不是原装军队,就像是替补,所以也就演变叫做猴子补丁
另一种说法“monkeying about”有胡闹,顽皮,哄骗的意思,所以叫做猴子补丁
python中使用猴子补丁


如果你对python感兴趣,我这有个学习
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值