def convert2pstats(stats):
if not isinstance(stats, YFuncStats):<EOL><INDENT>raise YappiError("<STR_LIT>")<EOL><DEDENT>import pstats<EOL>class _PStatHolder:<EOL><INDENT>def __init__(self, d):<EOL><INDENT>self.stats = d<EOL><DEDENT>def create_stats(self):<EOL><INDENT>pass                <EOL><DEDENT><DEDENT>def pstat_id(fs):<EOL><INDENT>return (fs.module, fs.lineno, fs.name)<EOL><DEDENT>_pdict = {}<EOL>_callers = {}<EOL>for fs in stats:<EOL><INDENT>if not fs in _callers:<EOL><INDENT>_callers[fs] = {}<EOL><DEDENT>for ct in fs.children:<EOL><INDENT>if not ct in _callers:<EOL><INDENT>_callers[ct] = {}<EOL><DEDENT>_callers[ct][pstat_id(fs)] = (ct.ncall, ct.nactualcall, ct.tsub ,ct.ttot)<EOL><DEDENT><DEDENT>for fs in stats:<EOL><INDENT>_pdict[pstat_id(fs)] = (fs.ncall, fs.nactualcall, fs.tsub, fs.ttot, _callers[fs], )        <EOL><DEDENT>return pstats.Stats(_PStatHolder(_pdict))<EOL>
Converts the internal stat type of yappi(which is returned by a call to YFuncStats.get())
as pstats object.