Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
29c0afcf
Commit
29c0afcf
authored
Apr 28, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just added comments, and cleared some XXX questions, related to int
memory management.
parent
449b5a8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
Objects/intobject.c
Objects/intobject.c
+12
-3
No files found.
Objects/intobject.c
View file @
29c0afcf
...
...
@@ -26,11 +26,18 @@ err_ovf(char *msg)
/* Integers are quite normal objects, to make object handling uniform.
(Using odd pointers to represent integers would save much space
but require extra checks for this special case throughout the code.)
Since
,
a typical Python program spends much of its time allocating
Since a typical Python program spends much of its time allocating
and deallocating integers, these operations should be very fast.
Therefore we use a dedicated allocation scheme with a much lower
overhead (in space and time) than straight malloc(): a simple
dedicated free list, filled when necessary with memory from malloc().
block_list is a singly-linked list of all PyIntBlocks ever allocated,
linked via their next members. PyIntBlocks are never returned to the
system before shutdown (PyInt_Fini).
free_list is a singly-linked list of available PyIntObjects, linked
via abuse of their ob_type members.
*/
#define BLOCK_SIZE 1000
/* 1K less typical malloc overhead */
...
...
@@ -51,12 +58,14 @@ static PyIntObject *
fill_free_list
(
void
)
{
PyIntObject
*
p
,
*
q
;
/*
XXX Int blocks escape the object heap. Use PyObject_MALLOC ???
*/
/*
Python's object allocator isn't appropriate for large blocks.
*/
p
=
(
PyIntObject
*
)
PyMem_MALLOC
(
sizeof
(
PyIntBlock
));
if
(
p
==
NULL
)
return
(
PyIntObject
*
)
PyErr_NoMemory
();
((
PyIntBlock
*
)
p
)
->
next
=
block_list
;
block_list
=
(
PyIntBlock
*
)
p
;
/* Link the int objects together, from rear to front, then return
the address of the last int object in the block. */
p
=
&
((
PyIntBlock
*
)
p
)
->
objects
[
0
];
q
=
p
+
N_INTOBJECTS
;
while
(
--
q
>
p
)
...
...
@@ -975,7 +984,7 @@ PyInt_Fini(void)
}
}
else
{
PyMem_FREE
(
list
);
/* XXX PyObject_FREE ??? */
PyMem_FREE
(
list
);
bf
++
;
}
isum
+=
irem
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment