【问题标题】:python Built-in Functions principle? [duplicate]python内置函数原理? [复制]
【发布时间】:2016-08-29 19:23:19
【问题描述】:

当我阅读 python 源代码时,我发现了像

这样的内置函数
class staticmethod(object):
    """
    ....
    """
    def __getattribute__(self, name): # real signature unknown; restored from __doc__
        """ x.__getattribute__('name') <==> x.name """
        pass

    def __get__(self, obj, type=None): # real signature unknown; restored from __doc__
        """ descr.__get__(obj[, type]) -> value """
        pass

    def __init__(self, function): # real signature unknown; restored from __doc__
        pass

    @staticmethod # known case of __new__
    def __new__(S, *more): # real signature unknown; restored from __doc__
        """ T.__new__(S, ...) -> a new object with type S, a subtype of T """
        pass

    __func__ = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default

我的问题是空方法有什么用?为什么写在这里?

【问题讨论】:

  • 请编辑您的帖子并添加更多详细信息,这是哪个库/模块?提及名称。

标签: python


【解决方案1】:

Python 的一些(可能是大多数)内置函数是用 C 编写的,因此没有针对它们的 Python 实现。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-17
    • 2018-03-04
    • 1970-01-01
    • 2023-01-19
    • 1970-01-01
    • 1970-01-01
    • 2021-06-12
    相关资源
    最近更新 更多