关闭python引用计数输出

2024-05-28 19:42:15 发布

您现在位置:Python中文网/ 问答频道 /正文

所以,每当我在Python中做任何事情时,我总是得到这个refs count输出。例如:

xxxxx@li282-82:~$ python
Python 2.7.3 (default, Feb 28 2013, 20:42:30) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
[40347 refs]
>>> django.VERSION
(1, 5, 2, 'final', 0)
[40349 refs]
>>> 
[40349 refs]
[19961 refs]
xxxxx@li282-82:~$ logout

我该怎么关掉它?!你知道吗


Tags: djangodefaultontypecounthelp事情feb
3条回答

Misc/SpecialBuilds.txt

Py_REF_DEBUG


Turn on aggregate reference counting. This arranges that extern _Py_RefTotal hold a count of all references, the sum of ob_refcnt across all objects. In a debug-mode build, this is where the "8288" comes from in

>>> 23
23
[8288 refs]
>>>

Note that if this count increases when you're not storing away new objects, there's probably a leak. Remember, though, that in interactive mode the special name "_" holds a reference to the last result displayed!

Py_REF_DEBUG also checks after every decref to verify that the refcount hasn't gone negative, and causes an immediate fatal error if it has.

Special gimmicks:

    sys.gettotalrefcount()
    Return current total of all refcounts.

Py_REF_DEBUG也被其他一些调试选项所暗示。但是每个人都是对的:不知何故或者你有一个Python的调试版本。你知道吗

正如@mgilson所建议的,您可能已经安装了源代码编译的Python(/usr/local/bin/python暗示)。如果您想从源代码处重建Python,请下载所需版本的最新源代码,并按照以下说明进行操作:

tar jxvf Python-x.y.z.tar.bz2
cd Python-x.y.z
./configure  prefix=/usr/local \
             mandir=/usr/local/man \
             enable-shared \
             with-threads \
             enable-ipv6 \
             with-dbmliborder=gdbm
make
make install

见:http://docs.python.org/2/using/unix.html#building-python

在我看来,您的解释程序是用debug flag编译的。为了摆脱它,我想你需要重新编译。你知道吗

相关问题 更多 >

    热门问题