<br><br><div class="gmail_quote">On Sat, Apr 5, 2008 at 3:00 PM, Jim Jewett <<a href="mailto:jimjjewett@gmail.com">jimjjewett@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
How have you decided which attributes are CPython-specific?<br>
I'm not saying your decisions are wrong, but I find all of them at<br>
least up for questioning.<br>
<br>
Those marked non-CPython-specific<br>
============================<br>
<br>
- argv<br>
<br>
Does this make sense for embedded python?</blockquote><div>Maybe, that doesn't mean it shouldn't be there. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
- byteorder<br>
<br>
This seems fairly low-level. I wouldn't expect to need it if working<br>
strictly at the python level, unless writing wire-protocols *and*<br>
working with objects larger than bytes.<br>
<br>
If you do need it, should text representation (UCS2 vs UCS4 vs UTF8 vs<br>
bytestrings) be exposed?</blockquote><div>It should probably go to platform. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<div class="Ih2E3d"><br>
- builtin_module_names, path, and modules<br>
<br>
</div>I'm not sure why these three are together.<br>
What is the builtin_module_names?</blockquote><div>Modules which are compiled into the interpreter (like sys and nt, mac, or posix). Maybe, it should go to interpreter.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
sys.path might be an oddball on a database-based system, such as classic PalmOS.<br>
<div class="Ih2E3d"><br>
- subversion, copyright, hexversion, version, and version_info<br>
<br>
</div>These do seem reasonable; they refer to the executable. Though even<br>
then, I wonder if there should be a way to extend it for<br>
customizations. ("embedded in XYZ", or "without unicode")<br>
<div class="Ih2E3d"><br>
- displayhook, __displayhook__<br>
- excepthook, __excepthook__, exc_info, and exc_clear<br>
<br>
</div>Are these required of every implementation?</blockquote><div>Every one that wants to work. :) <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<div class="Ih2E3d"><br>
- exec_prefix and prefix<br>
- executable<br>
- exit<br>
<br>
</div>Are these? And do they make sense when embedded?</blockquote><div>sys.executable and exec_prefix is allowed to be empty.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<div class="Ih2E3d"><br>
- flags, py3kwarning, dont_write_bytecode, and warn_options<br>
<br>
</div>Is the bytecode stage itself a crucial part of the langauge? I had<br>
thought of the the bytecode as an implementation detail, and so<br>
whether or not to write it out would seem even more<br>
implementation-specific.</blockquote><div>What the bytecode is and how it is generated is implementation specific. It's not the fact you're writing it or not. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
- getfilesystemencoding<br>
<br>
OK; but this seems to interact with text representation and path.<br>
<br>
- get/setprofile<br>
- get/settrace<br>
<br>
These seem as CPython-specific as anything frame-related.</blockquote><div>Jython provides them. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
- getwindowsversion<br>
<br>
This obviously doesn't make sense on a non-windows machine; why isn't<br>
it in platform instead of sys?<br>
<br>
- maxint and maxunicode<br>
<br>
I'm not sure what value these have. I assume maxint doesn't include<br>
longs -- so is it just the maximum efficiently represented integer, or<br>
is this specific to C extensions, or ..?</blockquote><div>The maximum int on the system. Jython provides this.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
And is maxunicode just roundabout way of figuring out the concrete<br>
representation (code points) of unicode characters?</blockquote><div>It is the max Unicode character that Python's unicode implementation is capable of handling. Jython provides this.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
- platform<br>
<br>
Should this be subsumed by the platform module?</blockquote><div>Hmm. I don't know. For basic platform tests, this sure is easy. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
- ps1 and ps2<br>
<br>
This really seems like a config issue rather than sys.</blockquote><div>Yeh, sys is about runtime Python. Besides, it's global to all implementations. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<div class="Ih2E3d"><br>
- stdin, stderr, stdout, __stdin__, __stderr__, __stdout__<br>
<br>
</div>These, at least, are clear -- to the extent that they make sense. (In<br>
some environments, they don't.)<br>
<br>
- tracebacklimit<br>
<br>
How is this different from setrecursionlimit?</blockquote><div>It defines how many lines of traceback are printed in an exception. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
Those marked CPython-specific<br>
=========================<br>
<br>
- get/setrecursionlimit<br>
- get/setcheckinterval<br>
<br>
These are runtime characteristics, but I don't see them (necessarily)<br>
being tied to the implementation. Just returning False to say the<br>
limit isn't relevant makes sense, and returning some huge number may<br>
work in practice. If you care enough to say "Can I recurse 3000<br>
frames?", that is a legitimate question, and it just so happens that<br>
Jython should always answer "yes".</blockquote><div>Actually, I believe you get a stack overflow before that. It doesn't tell you that. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
- _getframe and _current_frame<br>
<br>
I expect the details of a frame may be different with different<br>
implementations, but is there an implemenation that doesn't have<br>
frames at all? (I could imagine that it is a pain to get a frame from<br>
a compiled version, but the Java tracebacks and introspection need<br>
something roughly equivalent.)</blockquote><div>Well, it's not there now... <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
- getrefcount<br>
<br>
This should probably be in gc, rather that sys.<br>
<div class="Ih2E3d"><br>
- get/setdlopenflags<br>
- settscdumps<br>
- api_version<br>
- winver<br>
- dllhandle<br>
- float_info<br>
<br>
</div>I don't find all of these in 2.5 help(sys), but to the extent I<br>
understand them, they are about extensions rather the system. If<br>
Python under java or .net did open .dlls or support ffi extensions, I<br>
would expect a similar API.</blockquote><div>Some of them are new in 2.6. Look at those docs. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<div class="Ih2E3d"><br>
- _compact_freelists<br>
- _clear_type_cache<br>
<br>
</div>These should probably be in gc, rather that sys.<br>
<br>
<br>
To summarize my alternative<br>
======================<br>
<br>
sys -- representing the built system<br>
<div class="Ih2E3d"><br>
- subversion, copyright, hexversion, version, and version_info<br>
</div> - builtin_module_names<br>
<div class="Ih2E3d"> - exec_prefix and prefix<br>
- executable<br>
- exit<br>
<br>
</div>gc -- representing memory management<br>
<br>
- getrefcount<br>
<div class="Ih2E3d"> - _compact_freelists<br>
- _clear_type_cache<br>
<br>
</div>platform -- representing the OS environment<br>
- getfilesystemencoding<br>
- getwindowsversion<br>
- platform<br>
<br>
runtime -- representing this particular runtime environment</blockquote><div>Sys is the runtime environment. We don't need a new module for that.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
- argv<br>
- path (today's sys.path, not os.path)<br>
- modules<br>
<div class="Ih2E3d"> - displayhook, __displayhook__<br>
- excepthook, __excepthook__, exc_info, and exc_clear<br>
</div> - flags<br>
- py3kwarning, warn_options (why are these not just in warnings?)<br>
- dont_write_bytecode<br>
- get/setprofile<br>
- get/settrace<br>
<div class="Ih2E3d"> - ps1 and ps2<br>
- stdin, stderr, stdout, __stdin__, __stderr__, __stdout__<br>
<br>
- tracebacklimit<br>
</div><div class="Ih2E3d"> - get/setrecursionlimit<br>
- get/setcheckinterval<br>
- _getframe and _current_frame<br>
<br>
<br>
</div>ffi -- representing bit-level foreign function interface details<br>
(maybe tied to ctypes?)<br>
<br>
- byteorder<br>
- maxint and maxunicode<br>
- get/setdlopenflags<br>
- settscdumps # I'm not sure what this one is<br>
<div class="Ih2E3d"> - api_version<br>
- winver<br>
- dllhandle<br>
- float_info<br>
<br>
<br>
</div>(whehter os and os.path should also be mixed in to the reorg ... is a<br>
different question.)<br>
<font color="#888888"><br>
-jJ<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br>Benjamin Peterson