WEBVTT

00:00.210 --> 00:08.160
Now when I have this list what I'm gonna do is I'm going to store in a variable let me see a size of

00:08.700 --> 00:09.280
list.

00:09.330 --> 00:14.210
Size of list OK and size of list is available.

00:14.670 --> 00:19.350
And I'm going to get the size by using the size get size or function.

00:19.350 --> 00:24.750
If you remember the get size of function from the system or do I have color size and I'm going to use

00:24.750 --> 00:31.210
that function now and I'm going to say size often I'm going to pass the LSD right.

00:31.610 --> 00:32.370
OK.

00:32.370 --> 00:40.170
Let me just print size of list so I'll print size of this.

00:40.890 --> 00:42.540
And all I can say.

00:42.540 --> 00:43.860
Come on.

00:43.920 --> 00:45.270
Sorry.

00:45.270 --> 00:46.380
Size of list.

00:48.070 --> 00:49.680
And there we are.

00:49.750 --> 00:52.660
So size of list is 88.

00:52.750 --> 00:54.070
Now comes the question.

00:54.400 --> 00:56.950
Is this the total size of the list.

00:56.950 --> 01:02.350
Is this a total totalist the size of a list of cause of just three elements is eighty eight bytes.

01:02.370 --> 01:04.140
OK that's fair enough.

01:04.270 --> 01:10.930
But is this the size of the list or is this the size of these three elements along with the list or

01:10.930 --> 01:14.290
is there more to a list let's understand.

01:14.500 --> 01:16.640
Let's first take an empty set.

01:16.660 --> 01:22.710
Let me call it as an empty empty LSD and emptiness What is the size of an empty list.

01:22.720 --> 01:23.710
Let's have a look.

01:23.710 --> 01:28.080
So I'm going to say size of empty suit

01:32.720 --> 01:35.790
is equal to size of.

01:36.020 --> 01:45.950
And then I can use the list I can pass that into though and then I can of course print up the size of

01:46.040 --> 01:46.730
empty list

01:50.210 --> 01:50.510
right.

01:50.510 --> 01:55.910
So the size of the empty list itself without any of these elements is 64.

01:56.390 --> 02:01.900
Which means each each element inside this list takes takes how much.

02:02.000 --> 02:05.430
88 minus 64 that is.

02:05.540 --> 02:10.850
That is we have 24:24 divide by three that is it by each.

02:10.850 --> 02:17.410
So 64 bytes is for an empty list 8 bytes each for each element in this list.

02:17.600 --> 02:26.420
Eight bytes each for each element in this list right now if I dive further if I ask you further what

02:26.420 --> 02:29.010
are these elements what are these elements.

02:29.060 --> 02:32.130
Are there elements directly or are the objects.

02:32.240 --> 02:34.010
Or are there references to an object.

02:34.010 --> 02:39.010
If you remember in Python none of these are elements.

02:39.410 --> 02:41.100
None of them are values itself.

02:41.120 --> 02:43.210
They are references to objects.

02:43.310 --> 02:43.790
Right.

02:43.940 --> 02:54.280
How do I come to know that if I print the type of of LSD of zero.

02:54.370 --> 03:01.210
That's the first element if I print the type of that it is class Integer which means this is a reference

03:01.210 --> 03:03.400
to an object of type class Integer.

03:03.400 --> 03:11.730
So that means the size which we have got here is an empty list size plus another 24 bytes.

03:11.770 --> 03:19.190
Those 24 bytes does not belong to the exact element the values they actually belong to.

03:19.420 --> 03:25.330
They actually belong to not just Elliman values but they belong to the references to an object.

03:25.330 --> 03:30.700
So that means the size of each of these elements will be.

03:30.700 --> 03:34.190
Is is it added the size of this is this a reference to the list.

03:34.240 --> 03:40.120
Basically when I say size of list this is best in the memory space that is going to create a list which

03:40.130 --> 03:48.760
is going to have some overhead data of 64 bytes along with as many number of elements then along with

03:48.760 --> 03:51.310
the corresponding to those number of elements.

03:51.310 --> 03:53.280
There will be number of references.

03:53.410 --> 03:57.770
Those references are stored in 64 bytes.

03:57.920 --> 04:00.510
So in 24 bytes right.

04:00.550 --> 04:01.570
For each element.

04:01.600 --> 04:09.090
Ed bitis taken to sort of reference but those reference are nothing but pointing to another.

04:09.160 --> 04:10.710
It's a completely different.

04:10.720 --> 04:18.480
Those references are finally pointing to pointing to elements of type integer.

04:18.660 --> 04:19.090
Right.

04:19.090 --> 04:26.470
So that means each of the elements in this list finally have more more size.

04:26.500 --> 04:36.010
That means if I would say size of LSD of zero size of LSD abse you this will give me the actual size

04:36.130 --> 04:39.710
of each of the elements more than the differences.

04:39.740 --> 04:40.550
OK.

04:40.810 --> 04:44.180
So the size of each element this word granted.

04:44.230 --> 04:52.960
So if I say total size total size when you define a list total size when you define a list will be first

04:52.960 --> 05:03.640
of all the size of list as we just saw over here the size of list but also along with that the size

05:03.640 --> 05:05.970
of each elements plus.

05:06.190 --> 05:12.640
OK so maybe just before this I can just you know I can just keep this aside and I can say I can just

05:12.640 --> 05:16.530
define size of each element.

05:19.110 --> 05:21.550
Enlist right each element.

05:21.630 --> 05:28.310
Let me just put that up in you of each element and that can be size of LSD of zero.

05:28.380 --> 05:29.100
Right.

05:30.910 --> 05:35.000
LSD of zero and that's size of each element.

05:35.000 --> 05:41.290
Now if you want to print it of course you can have size of each element being printed that's 28 we already

05:41.290 --> 05:42.040
saw that.

05:42.250 --> 05:54.630
But total size is going to be that size which is going to be equal to the size of list plus plus the

05:55.010 --> 06:05.930
Lenn all lendin all I can say of each the length of the total number of you know total number of elements

06:05.930 --> 06:13.430
in the list I can get that with Lanuf LSD and then multiply that size of each element right size of

06:13.430 --> 06:14.190
each element.

06:14.450 --> 06:20.160
And this would be the total size so if I print the total size this is going to be total size.

06:20.450 --> 06:26.580
So you can have a look for a list of three elements the total size is 172.

06:26.870 --> 06:27.560
Wow.

06:27.950 --> 06:35.270
That's a size of all the memory consumption in the list the memory consumed in the list is actually

06:35.330 --> 06:40.430
the total size is the list size of the entire list plus the size of each element because the size of

06:40.430 --> 06:47.720
the list only consists of references of objects whereas each object has its own size multiplied by the

06:47.720 --> 06:49.420
number of objects in the list.

06:49.490 --> 06:51.850
So total size will be 172.

06:51.890 --> 06:54.800
That's the total in memory consumed by a list.

06:54.800 --> 07:00.700
Now let's go want to figure out what will be the memory consumed in an empty attic right.
