where to view open() function's C implementation source code ?

R

Roy Smith

iMath said:
Â� 2012”N12ŒŽ18“�Â�Š�“�UTC+8‰�Œ�1æ—¶35分58秒,Roy Smith写é“:

but which python module is open() in ?

I met you half-way, I showed you where the source code is. Now you
need to come the other half and look at the code. Maybe start by
grepping the entire source tree for "open"?
 
C

Chris Angelico

I met you half-way, I showed you where the source code is. Now you
need to come the other half and look at the code. Maybe start by
grepping the entire source tree for "open"?

Ouch, that mightn't be very effective! With some function names, you
could do that. Not so much "open". Still, it'd be a start...

ChrisA
 
R

rurpy

http://www.python.org/download/releases/
Download the source for the version you're interested in.

iMath:

There is no need to download the source. You can browse the
source code online. For the v3.0.0 version of open():
hg.python.org/cpython/file/bd8afb90ebf2/Modules/_io/_iomodule.c

For 2.7.3 I think what you want is the builtin_open() function in
http://hg.python.org/cpython/file/70274d53c1dd/Python/bltinmodule.c
and the file object and open_the_file() function in
http://hg.python.org/cpython/file/70274d53c1dd/Objects/fileobject.c

Hope this helps.
 
A

Andrew Robinson

Ouch, that mightn't be very effective! With some function names, you
could do that. Not so much "open". Still, it'd be a start...

ChrisA
In Python3.3.0 -- the built in open() appears in
Python-3.3.0/Modules/_io/_iomodule.c;
There is another module defined in an object in
Python-3.3.0/Modules/_io/fileio.c; but I don't think that the one called
when a lone x=open(...) is done.

Cheers.
--Andrew.
 
I

iMath

在 2012å¹´12月19日星期三UTC+8上åˆ4æ—¶57分37秒,[email protected]写é“:
iMath:



There is no need to download the source. You can browse the

source code online. For the v3.0.0 version of open():

hg.python.org/cpython/file/bd8afb90ebf2/Modules/_io/_iomodule.c



For 2.7.3 I think what you want is the builtin_open() function in

http://hg.python.org/cpython/file/70274d53c1dd/Python/bltinmodule.c

and the file object and open_the_file() function in

http://hg.python.org/cpython/file/70274d53c1dd/Objects/fileobject.c



Hope this helps.

thanks very much !
 
I

iMath

在 2012å¹´12月19日星期三UTC+8上åˆ4æ—¶57分37秒,[email protected]写é“:
iMath:



There is no need to download the source. You can browse the

source code online. For the v3.0.0 version of open():

hg.python.org/cpython/file/bd8afb90ebf2/Modules/_io/_iomodule.c



For 2.7.3 I think what you want is the builtin_open() function in

http://hg.python.org/cpython/file/70274d53c1dd/Python/bltinmodule.c

and the file object and open_the_file() function in

http://hg.python.org/cpython/file/70274d53c1dd/Objects/fileobject.c



Hope this helps.

thanks very much !
 
R

rurpy

在 2012å¹´12月19日星期三UTC+8上åˆ4æ—¶57分37秒,[email protected]写é“:
[...]
There is no need to download the source. You can browse the
source code online. For the v3.0.0 version of open():
hg.python.org/cpython/file/bd8afb90ebf2/Modules/_io/_iomodule.c

For 2.7.3 I think what you want is the builtin_open() function in
http://hg.python.org/cpython/file/70274d53c1dd/Python/bltinmodule.c
and the file object and open_the_file() function in
http://hg.python.org/cpython/file/70274d53c1dd/Objects/fileobject.c

Hope this helps.

thanks very much !

Your welcome.

I noticed that you, like me, are using Google Groups. You
might want to read this page about posting from Google Groups:

http://wiki.python.org/moin/GoogleGroupsPython

It will help you avoid double posts and other Google Groups
posting problems that annoy other people here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top