在Python中为方法生成控制流图的最简单方法是什么? [英] What is the easiest way to generate a Control Flow-Graph for a method in Python?

查看:744
本文介绍了在Python中为方法生成控制流图的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个试图比较两种方法的程序。我想为所有匹配的方法生成控制流图(CFG),并使用拓扑排序来比较两个图。

解决方案

RPython PyPy 后面的翻译工具链,提供了一种抓取流程图(位于 / rpython / rpython / flowspace /?at = defaultrel =nofollow> https://rpython.readthedocs.io/en/latest/translation.html#the-annotation-pass =nofollow>类型推断



这在大多数情况下工作得很好,但不支持生成器。结果将以SSA形式出现,这可能是好的或坏的,取决于你想要的。


I am writing a program that tries to compare two methods. I would like to generate Control flow graphs (CFG) for all matched methods and use either a topological sort to compare the two graphs.

解决方案

RPython, the translation toolchain behind PyPy, offers a way of grabbing the flow graph (in the pypy/rpython/flowspace directory of the PyPy project) for type inference.

This works quite well in most cases but generators are not supported. The result will be in SSA form, which might be good or bad, depending on what you want.

这篇关于在Python中为方法生成控制流图的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆