[Python-Dev] newb question
Hi, I'm new to the Python source and I have a (hopefully) quick question that someone more familiar with it should be able to answer so I can continue on my way to understanding how Python is put together. I have started looking at the parser and have gotten a little confused about how the grammar is instantiated (perhaps the wrong term). Here's how I understand things at the moment. graminit.c contains the definition of the grammar in terms of static structures. Everything seems simple enough until I get to the DFA (in graminit.c): static dfa dfas[84] = { {256, "single_input", 0, 3, states_0, "\004\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\006\201"}, ... I assume that the last bit of my snippet (\004\050\014\ ...) is a bitset structure. When I look at bitset it is defined as a char array. Can someone explain how this works please? I've never come across escape sequences like this; I've only ever seen \0 (nul) before; not \2, \3 etc. or are they not escape sequences, but literal forward slashes. Thanks, Ty ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Porting information
Hi, I'm looking into porting CPython to native C# (not like IronPython) so that it can be used in game software on the XBox360: integrated with the indie development tool XNA Game Studio Express. I am looking for some guidance on how to approach this in the most effective way. I've started by looking at the parser portion of the code. However I am not certain this is the best place to start. Since there are so many ports I assume there is a well trodden path to completing this kind of task. Any suggestions would be greatly appreciated. I would prefer to break the task into portions that can be verified (tested for correctness) independently or as a stack (one on top of the next). That way I can catch errors early and have more confidence in what I am creating. When I looked through the test suites they all seem to be written in Python. Is there a test suite for the core of CPython i.e. before the C code can interpret Python code? Thanks, Ty ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Compiling cpython2.5.1 in VS2005?
Hi, I was building Python 2.5.1 in Visual Studio 2005 and noticed some problems with the instructions. Can someone confirm this and update the readme file in the PCbuild8 directory? I don't yet have access to the repository. This is what the readme.txt file says to do: All you need to do is open the workspace "pcbuild.sln" in VisualStudio 2005, select the platform, select the Debug or Release setting (using "Solution Configuration" from the "Standard" toolbar"), and build the solution. The proper order to build subprojects: 1) pythoncore (this builds the main Python DLL and library files, python25.{dll, lib} in Release mode) NOTE: in previous releases, this subproject was named after the release number, e.g. python20. 2) python (this builds the main Python executable, python.exe in Release mode) This is my experience. DEBUG configuration: When I select 'pythoncore' (right click) from the solution explorer, select 'project only', select 'build only pythoncore' I get this error report: Warning 1 warning C4005: 'Yield' : macro redefinition E:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winbase.h57 Warning 2 warning C4005: 'Yield' : macro redefinition E:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winbase.h57 Error 3 fatal error C1083: Cannot open source file: '.\getbuildinfo2.c': No such file or directory c1 It looks like the project dependencies are not kicking in. I assume this is caused by building the project instead of the solution. So I did them manually. First make_versioninfo project: I select 'make_versioninfo' (right click) from the solution explorer, select 'project only', select 'build only make_versioninfo'. This succeeds. Second make_buildinfo project: I select 'make_buildinfo' (right click) from the solution explorer, select 'project only', select 'build only make_buildinfo'. This succeeds. Finally I try to make pythoncore again: I select 'pythoncore' (right click) from the solution explorer, select 'project only', select 'build only pythoncore'. This succeeds. Now I build python and it also succeeds. One last thing I noticed is if there are spaces in the path of the source files the compilation also fails. Regards, Ty ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Compiling cpython2.5.1 in VS2005?
oh, sorry. I'll do that. Ty Martin v. Löwis wrote: >> Can someone confirm this and update the readme file in the PCbuild8 >> directory? I don't yet have access to the repository. > > Please provide patches instead, and post them on bugs.python.org. > > Regards, > Martin > > ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Porting information
Thanks Martin, Martin v. Löwis wrote: >> I've started by looking at the parser portion of the code. However I am >> not certain this is the best place to start. Since there are so many >> ports I assume there is a well trodden path to completing this kind of >> task. > > I believe this assumption is wrong. There are not many ports, only a > handful (or less - Jython, IronPython, PyPy). While Jython and > IronPython may have similar implementation strategies, I would expect > that PyPy took an entirely different approach. > > In any case, there certainly is a step that you apparently failed > to perform as the very first step: set some explicit goals. What > kind of compatibility do you want to achieve in your port, what > other goals would you like to follow? > I thought I'd try and keep my message short so I decided not to go into the explicit objectives. At the most basic it is the ability for developers to run compiled Python as part of the game code. The next step up from that is allowing Python source code to execute and be modified in a 'simple' interactive coding tool: allowing for 'tweaking' code to be implemented outside of the game engine team. Principal constraint: Microsoft support for independent development on the 360 is only provided through the use of their slimmed down .Net compact framework and the XNA Game Studio Express development environment (C# only). This allows Microsoft to implement security within the tool chain and deployment pipeline to sandbox strictly. > IOW, why is IronPython not what you want (it *is* a port of CPython > to C#, in a sense), and why is the C# support in PyPy not good enough > for you? > The impact, to this project, of the reduced API and strict sandboxing in the 360 dev environment is Python implementations like IronPython are not feasible. IronPython uses the reflection capabilities of C# to interpret directly to CLR. Without reflection IronPython simply cannot operate. Unfortunately the 360 API does not include reflection functionality. I had a look into PyPy and concluded that it could produce a result that would operate however I was less certain about integrating it into a development tool chain for the 360. It seems more likely that a 'C#Python' would result in a cleaner development environment - much like the embedded inclusion of Lua scripting in many games software. >> I would prefer to break the task into portions that can be verified >> (tested for correctness) independently or as a stack (one on top of the >> next). That way I can catch errors early and have more confidence in >> what I am creating. > > As I don't know what you want to achieve, it is difficult to tell > you what steps to take. > > I assume your implementation would be similar to CPython in that > it uses the same byte code format. So one path would be to ignore > the compiler at all, and assume that the byte code format is given, > i.e. start with port ceval.c. > > I'm not sure whether you also want to provide the same low-level > API (i.e. whether you want to provide "Embedding and Extending"); > it surely can't be the *same* API, since your's will be C#, whereas > CPython's is, well, C. If you implement ceval.c, you will find > quickly that you need much of the Objects folder, so implementing > the 10 or so most important objects would be the natural starting > point (type, int, string, tuple, dict, frame, code, class, method - > assuming you would target Python 1.5 first, i.e. no bool, cell, > descr, gen, iter, weakref, unicode, object). > >> When I looked through the test suites they all seem to be written in >> Python. Is there a test suite for the core of CPython i.e. before the C >> code can interpret Python code? > > Yes and no. The core Python is tested through compilation - if it > compiles without warnings on the relevant compilers, it is considered > good enough to run the Python test suite. For selected features of > the interpreter, there are specific tests, in particular test_capi. > > The core of CPython (compiler, objects, builtins) is then tested > through Python code. > This seems like a sensible way to start since the test harness needs a Python interpreter. Although it seems counter-intuitive to build the bytecode interpreter so that I can test the bytecode compiler... > Regards, > Martin > > Thanks for the advice Martin. Regards, Ty ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com