object internals Flashcards

1
Q

dictionary of object attributes

A

__dict__

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

when __getattr__ invoked

A

invokes when property not found by normal lookup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

when __getattribute__ invoked

A

instead of normal lookup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

method for setting attributes

A

__setattr__(self, item, value)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

method for deleting attributes

A

__delattr__(self, item)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

function to access __dict__

A

vars()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

special method with __getattribute__

A

repr(a) invoke a.__repr__ without __getattribute__

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

get size of an object

A

sys.getsizeof(d)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

attribute of a class that reduce memory usage

A

__slots__

How well did you know this?
1
Not at all
2
3
4
5
Perfectly