profile.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:data_profiler 作者: numba 项目源码 文件源码
def __init__(self, frame, name=None):

        self.code = c = frame.f_code
        self.filename = c.co_filename
        self.lineno = c.co_firstlineno
        self.name = name or c.co_name
        # builtin methods report as name <method '...' of '...' objects>
        # Extract their real name from that.
        if self.name.startswith('<method '):
            self.name = self.name.split("'", 3)[1]
        arg_info = inspect.getargvalues(frame)
        args=[]
        # There are cases where we can't generate a signature...
        no_signature=False
        if arg_info:
            for a in arg_info.args:
                # FIXME: There are cases where we don't know how to handle arguments.
                #        If 'a' is a list, we bail out...
                if type(a) is list:
                    no_signature=True
                    break
                else:
                    v = arg_info.locals.get(a, None)
                if type(v) == numpy.ndarray:
                    t = 'ndarray(dtype=%s, shape=%s)'%(v.dtype, v.shape)
                # cython-compiled code doesn't report a locals dict, so 'v' may be None
                elif v is None:
                    t = '<unknown>'
                else:
                    t = str(type(v).__name__)
                args.append((a, t))
        self.args = no_signature and None or tuple(args)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号