views:

96

answers:

3

My question is very straight forward: Is smtplib pure python or implemented in C?

+3  A: 

smtplib itself is implemented in python but socket is based on C, so its means both.

S.Mark
Thanks Mark! That's what I was looking for.
Viet
+1  A: 

Basically pure Python (as the underlying implementation if you go down far enough is C). You can find the source under the Lib\ directory in your Python root.

Wayne Koorts
thanks Wayne! I gave both answers +1 and thank you very much for participation. Since Mark arrived first, I give him the green mark. Thank you very much!
Viet
+6  A: 
In [32]: import smtplib

In [33]: smtplib
Out[33]: <module 'smtplib' from '/usr/lib/python2.6/smtplib.pyc'>

Therefore, smtplib is written in python.

unutbu
+1 for showing how to find the answer, not just giving it.
Kiv
+1Hi ~unutbu! That's a neat way to investigate :D Thanks for the trick!
Viet
Not to be picky, but this wouldn't detect if smtplib is using a helper module (as part of the library) that is a native.
notnoop
@notnoop: That's true, but since every Python implementation (other than PyPy) is written in another language, every module depends on something which is non-Python if you dig deep enough. Therefore I interpreted the question to mean, "Is the module itself written in Python?"
unutbu
Well, there are a few modules whose Python module part is but a slim wrapper with a extra functions over the main implementation part from a _module C implementation.
bobince