[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-07-16 Thread Robert Schuppenies
Robert Schuppenies <[EMAIL PROTECTED]> added the comment: Fixed in r64842. -- resolution: -> fixed status: open -> closed ___ Python tracker <[EMAIL PROTECTED]> ___ __

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-07-03 Thread Robert Schuppenies
Robert Schuppenies <[EMAIL PROTECTED]> added the comment: Amaury, I was testing your patch and it turns out, that it will ignore any __sizeof__ attribute which may be available through getattr. I adapted it a bit, so now getsizeof will try to call the method on the passed object first, and if it

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-07-02 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: It now works for SRE objects in the py3k branch since r64672, but my patch is still needed for types that define tp_getattr. ___ Python tracker <[EMAIL PROTECTED]> _

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-27 Thread Robert Schuppenies
Robert Schuppenies <[EMAIL PROTECTED]> added the comment: Okay, I get the point. With including unicode.defenc I already included a referenced object which was ruled out in the first place. And this for a good reason. What bugs me, though, is that this leaves out a potentially significant amount

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-27 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: > Caching itself is no criteria, but allocating memory without giving > the user a chance to find out should be (in this context). > ... calling match.regs creates a > tuple which is not there before, but cannot be removed > afterwards.

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-27 Thread Robert Schuppenies
Robert Schuppenies <[EMAIL PROTECTED]> added the comment: I was refering to the fact that something on the C level is cached without the Python user ever noticing that it wasn't there before. Caching itself is no criteria, but allocating memory without giving the user a chance to find out should

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-27 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: I don't understand the relation between "the member is cached" and "it counts in the object's sizeof". What does "cached" mean? Does 'self.x = 3' create a cached member? ___ Python tracker <[EMAIL P

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-27 Thread Robert Schuppenies
Robert Schuppenies <[EMAIL PROTECTED]> added the comment: You are right, the rule is to not include referenced objects. But, and this has been rather informal up to now, I handled transparently cached information as something that is added to the memory used by an object (see unicode.defenc). The

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-26 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: Robert, looking at your patch for the _sre module, I noticed that MatchObject.__sizeof__ includes the sizeof of one of its member (regs: a tuple of (begin, end) pairs). Why this one and not the others? I thought the rule (if there is a r

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-26 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: I wondered why getsizeof fails for _sre.SRE_Pattern objects when it succeeds for _socket.socket or struct.Struct. It turns out that _sre.SRE_Pattern defines the tp_getattr slot, and this prevents attribute lookup from searching the base

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-26 Thread Robert Schuppenies
Robert Schuppenies <[EMAIL PROTECTED]> added the comment: The attribute error is caused by pattern_getattr, which tries to find __sizeof__, fails and then sets the error message. I don't know if casting the error is the right thing to do. Actually, sys.getsizeof() should work on any type. Anothe

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-26 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: I think it would be better to give a TypeError rather than an AttributeError for objects that don't support __sizeof__ as per other special methods. -- nosy: +benjamin.peterson ___ Python tracke

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-26 Thread Robert Schuppenies
Robert Schuppenies <[EMAIL PROTECTED]> added the comment: What would be a good way to identify *all* possible types? When I started, I included all objects in /Objects, but obviously this is not sufficient. ___ Python tracker <[EMAIL PROTECTED]>

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-26 Thread Facundo Batista
Facundo Batista <[EMAIL PROTECTED]> added the comment: Robert, do you have a test suite for the sizeof functionality? If not, you should start one ASAP, ;) This test should be included in that suit... -- nosy: +facundobatista ___ Python tracker <[EM

[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

2008-06-16 Thread Robert Schuppenies
New submission from Robert Schuppenies <[EMAIL PROTECTED]>: >>> import re >>> import sys >>> r = re.compile('') >>> sys.getsizeof(r) Traceback (most recent call last): File "", line 1, in AttributeError: __sizeof__ This applies to objects of the types _sre.SRE_Pattern, _sre.SRE_Scanner, and _