Giter Club home page Giter Club logo

shedskin's Introduction

image

image

Shed Skin

Shed Skin is a transpiler, that can translate pure, but implicitly statically typed Python 3 programs into optimized C++. It can generate stand-alone programs or extension modules that can be imported and used in larger Python programs.

Besides the typing restriction, programs cannot freely use the Python standard library (although about 25 common modules, such as random and re, are currently supported). Also, not all Python features, such as nested functions and variable numbers of arguments, are supported (see the documentation for details).

For a set of 80 non-trivial programs (at over 25,000 lines in total (sloccount)), measurements show a typical speedup of 1-100 times over CPython.

Usage

Compile and run the 'hello, world!' (test.py) example under Linux/OSX:

shedskin build test
build/test

Under Windows:

shedskin build --conan test
build/Debug/test.exe

Restrictions

Shed Skin only supports a restricted subset of Python, so one should not expect a given program to compile without any changes, if possible at all. See the documentation for an overview of the limitations.

Installation

Shed Skin depends on some others projects, such as the Boehm garbage collector. Please see the documentation on how to install these.

Comparison

Some timings for the Shed Skin 'sieve' example (n=100000000) and several Python implementations/optimizers:

cpython 3.10.6:     13.4 seconds
cpython 3.11.0:     11.4
nuitka 0.6.16:      11.4
pypy 3.9.12:        5.8
numba 0.56.4:       2.5
shedskin (master):  1.9

Note that Numba defaults to int64 as integer type, while Shed Skin defaults to int32. Performance is practically equal when using shedskin --long.

Screenhots

Some screenshots of the example programs in action:

(pylot)

image

(mandelbrot2)

image

(c64)

image

(othello2)

image

(doom)

Left floating image

This video shows the dramatic difference in performance for the DOOM example before and after compilation

Contributors

The following people have contributed to Shed Skin development:

Shakeeb Alireza
Hakan Ardo
Brian Blais
Paul Boddie
François Boutines
Djamel Cherif
James Coughlan
Mark Dewing
Mark Dufour
Artem Egorkine
Michael Elkins
Moataz Elmasry
Enzo Erbano
Ernesto Ferro
Salvatore Ferro
FFAO
Victor Garcia
Luis M. Gonzales
Fahrzin Hemmati
Folkert van Heusden
Karel Heyse
Humhue
Johan Kristensen
Kousuke
Denis de Leeuw Duarte
Van Lindberg
David Marek
Douglas McNeil
Andy Miller
Jeff Miller
Danny Milosavljevic
Joaquin Abian Monux
John Nagle
Harri Pasanen
Brent Pedersen
Joris van Rantwijk
Retsyo
Pierre-Marie de Rodat
Jérémie Roquet
Mike Schrick
SirNotAppearingInThisTutorial
Paul Sokolevsky
Thomas Spura
Joerg Stippa
Dan Stromberg
Dave Tweed
Jaroslaw Tworek
Tony Veijalainen
Pavel Vinogradov
Jason Ye
Liu Zhenhai
Joris van Zwieten

shedskin's People

Contributors

arkanosis avatar arteme avatar brentp avatar dahaw avatar dependabot[bot] avatar devjohan avatar dstromberg avatar ernestoferro avatar fahhem avatar folkertvanheusden avatar fouc avatar humhue avatar joerghw avatar pfalcon avatar pmderodat avatar retsyo avatar shakeeb avatar shakfu avatar srepmub avatar tomspur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shedskin's Issues

Should include cstring

Issue by sanxiyn
6 Aug 2008 at 8:17 GMT
Originally opened on Google Code


To reproduce, run shedskin on the following program and compile with GCC 4.3:

print 'Hello, world!'

The error is:

/home/tinuviel/svn/shedskin/lib/builtin.cpp: In function
‘__shedskin__::str* __shedskin__::__add_strs(int, ...)’:
/home/tinuviel/svn/shedskin/lib/builtin.cpp:624: error: ‘memcpy’ was not
declared in this scope

Due to header reorganization done in GCC 4.3, GCC no longer includes many
headers implicitly. To use memcpy, one must include cstring.

Suggested fix:

Index: lib/builtin.hpp
===================================================================
--- lib/builtin.hpp (revision 291)
+++ lib/builtin.hpp (working copy)
@@ -15,6 +15,7 @@
 #include <fstream>
 #include <sstream>
 #include <cstdarg>
+#include <cstring>
 #include <cmath>
 #include <algorithm>
 #include <iterator>

Thanks!

make in OSX

Issue by matteo.bertini
24 Apr 2008 at 11:08 GMT
Originally opened on Google Code


This patch let me run 'make' in OSX (Leopard + MacPorts)
(needs boehmgc and pcre)

Attachments:

How to become a ShedSkin developer?

Issue by [email protected]
5 Apr 2008 at 9:02 GMT
Originally opened on Google Code


Hello everybody
I'm Damiano from Italy, i'm really interested to your project, I'm a Python
developer and i'm studing C++ too (but i'm new of this language).

I have any questions:
- How could i to contact the ShedSkin Author? i read his blog but i don't
saw his email.
- Where can I find an explanation of the project? How it works etc. etc.
- Could i help you to develop this project? i can study hard C++

Thanks su much
Have a good day

Bye bye

(excuse me, i'm English is not very good :))

KeyError during compile

Issue by [email protected]
7 Aug 2009 at 2:27 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. shedskin ftplib.py

What is the expected output? What do you see instead?
expected success, saw:

dbm@zareason /home/dbm/bench/uploadSirikata> shedskin ftplib.py
*** SHED SKIN Python-to-C++ Compiler 0.2 ***
Copyright 2005-2009 Mark Dufour; License GNU GPL version 3 (See LICENSE)

[iterative type analysis..]
******
iterations: 6 templates: 2098
[generating c++ code..]
Traceback (most recent call last):
  File "/usr/lib/shedskin/bin/ss.py", line 433, in <module>
    main()
  File "/usr/lib/shedskin/bin/ss.py", line 428, in main
    analysis(name)
  File "/usr/lib/shedskin/bin/ss.py", line 149, in analysis
    generate_code()
  File "/usr/lib/shedskin/bin/ss.py", line 285, in generate_code
    walk(module.ast, gv)
  File "/usr/lib/python2.5/compiler/visitor.py", line 106, in walk
    walker.preorder(tree, visitor)
  File "/usr/lib/python2.5/compiler/visitor.py", line 63, in preorder
    self.dispatch(tree, *args) # XXX *args make sense?
  File "/usr/lib/python2.5/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/usr/lib/shedskin/bin/cpp.py", line 500, in visitModule
    self.module_cpp(node)
  File "/usr/lib/shedskin/bin/cpp.py", line 411, in module_cpp
    self.class_cpp(child)
  File "/usr/lib/shedskin/bin/cpp.py", line 663, in class_cpp
    if getgx().merged_inh[var]:
KeyError: (static class Error, '__eq__')
dbm@zareason /home/dbm/bench/uploadSirikata> 


What version of the product are you using? On what operating system?
0.2, ubuntu 8.04

Please provide any additional information below.
this is a modified version of Python2.5 ftplib.py -- it works in pure python

Attachments:

Support compiling of local unknown python modules

Issue by Thomas Spura
23 Aug 2009 at 5:20 GMT
Originally opened on Google Code


If shedskin currently does not support an unknown python module, it exits
with "module not found".

With this patch, it tries to copy the module in a subdir "genmod" and tries
to compile it there. After that we can add this directory in the Makefile
so the programm can fetch the new module.cpp/.hpp from there.

The reason for generating "genmod" and not copy it to the lib dir is, that
anything from lib dir should be maintained and shipped by shedskin. But on
an installed system any other user should not be allowed to modify/add
files in this folder. Therefore this patch keeps anything in the local
folder in "genmod" (another better name proposal is welcomed^^).

Attachments:

A couple of compiler errors and deprecated warnings.

Issue by [email protected]
23 Aug 2008 at 6:36 GMT
Originally opened on Google Code


Out of the box, shedskin will fail to compile. This is because builtin.cpp
and sys.cpp are missing some necessary header includes.

builtin.cpp is missing "#include <cstring>". It needs this file because it
uses memcpy. sys.cpp is missing "#include <climits>". It needs this file
because it uses INT_MAX.

I am using g++ 4.3. Earlier versions of g++ were more forgiving when you
did not include necessary header files. g++ versions are becoming stricter
in that regard.

I'll add to this bug if I find any other cpp files missing includes.

Also, when building, I get a bunch of deprecation warnings that cloud the
output. Apparently, builtin.cpp includes ext/hash_map and ext/hash_set,
which are declared to be deprecated. They expect you to include
unordered_set and unordered_map instead. I'm not sure how far back these
new headers go, as in, I'm not sure which versions of g++ include these
headers. I recommend either upgrading to the new headers, or just adding
-Wno-deprecated to the CCFLAGS line.

I am using the latest stable version of shedskin (0.0.28) on a Debian
system, with g++ 4.3.

Illegal class member redefinition needs error message

Issue by [email protected]
23 Jan 2008 at 5:40 GMT
Originally opened on Google Code


The attached program initializes a member to 0, and then later redefines
the member to a class instance.  This is not allowed within the shedskin model.
However, it should give an error message rather than crashing.

Running shedskin gives this output:

Traceback (most recent call last):
  File "/home/user/software/python/shedskin/shedskin-0.0.26-1/ss.py", line
6815, in <module>
    main()
  File "/home/user/software/python/shedskin/shedskin-0.0.26-1/ss.py", line
6811, in main
    analysis(name)
  File "/home/user/software/python/shedskin/shedskin-0.0.26-1/ss.py", line
6534, in analysis
    analyze_virtuals()
  File "/home/user/software/python/shedskin/shedskin-0.0.26-1/ss.py", line
5444, in analyze_virtuals
    if [cl for cl in concrete_cl.ancestors_upto(abstract_cl) if ident in
cl.funcs and not cl.funcs[ident].inherited]:
  File "/home/user/software/python/shedskin/shedskin-0.0.26-1/ss.py", line
108, in ancestors_upto
    a = a.bases[0] 
IndexError: list index out of range



Attachments:

Support for @staticmethod

Issue by sanxiyn
6 Aug 2008 at 8:28 GMT
Originally opened on Google Code


The attached patch implements just enough to get @staticmethod decorator
working. Namely, the following code compiles:

class C:
    @staticmethod
    def id(x):
        return x
print C.id(1)

Attachments:

A library dependency needs to be made explicit

Issue by [email protected]
29 Jul 2008 at 11:26 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. tar cvf shedskin-0.0.28.tgz 
2. cp shedskin ~/bin
3. cd ../somewhere
4. shedskin vectorD.py   
5. make

What is the expected output? What do you see instead?

I expect to see compliation.   Instead, I see lots of error
messages indicating that some library is unavailable.

> $ make
> g++  -O3 -pipe -fomit-frame-pointer  -I.
-I/home/mace/gpk/DOWNLOADS/shedskin-0.0.28/lib
/home/mace/gpk/DOWNLOADS/shedskin-0.0.28/lib/builtin.cpp vectorD.cpp -lgc 
-o vectorD
> In file included from
/home/mace/gpk/DOWNLOADS/shedskin-0.0.28/lib/builtin.cpp:1:
> /home/mace/gpk/DOWNLOADS/shedskin-0.0.28/lib/builtin.hpp:8:29: error:
gc/gc_allocator.h: No such file or directory
> /home/mace/gpk/DOWNLOADS/shedskin-0.0.28/lib/builtin.hpp:9:23: error:
gc/gc_cpp.h: No such file or directory
> In file included from
/home/mace/gpk/DOWNLOADS/shedskin-0.0.28/lib/builtin.cpp:1:
> /home/mace/gpk/DOWNLOADS/shedskin-0.0.28/lib/builtin.hpp:156: error:
‘gc_allocator’ was not declared in this scope
> ...


What version of the product are you using? On what operating system?
shedskin 0.0.28
xubuntu 8.04

Please provide any additional information below.

All I really need is a little documentation on what libraries
are needed.   Ideally, the installer would check to make sure
they exist.

int/double conversion when initializing an array

Issue by [email protected]
7 Feb 2008 at 1:18 GMT
Originally opened on Google Code


The attached program gives different output when run from python and when
run under shedskin.

An array of doubles is initialized with an integer, and the type conversion
doesn't work correctly.

It appears to be a problem with variadic functions and type conversions (in
the list constructor).  See the attached vatest.cpp file.

One possible solution is to add explicit casts in the constructor call, eg
  charges = (new list<double>(1,(double)6));

Attachments:

input problem

Issue by [email protected]
20 Jun 2009 at 3:47 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. a = input(' ')
2.
3.

What is the expected output? What do you see instead?
To be able to use the input statement. An error from shedskin saying
"*ERROR* age.py:1: unbound identifier 'input'"

What version of the product are you using? On what operating system?
I'm usig shedskin 0.1.1. On windows xp.

Please provide any additional information below.
Please help with this situation. 

No errors or warnings, but can't compile

Issue by [email protected]
16 Jun 2009 at 6:31 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. make

This is the output on Fedora 11 x86_64:
g++  -O2 -pipe -Wno-deprecated  -I.
-I/home/frafra/Scaricati/shedskin-0.1.1/lib
/home/frafra/Scaricati/shedskin-0.1.1/lib/sys.cpp
/home/frafra/Scaricati/shedskin-0.1.1/lib/builtin.cpp life_shed.cpp
/home/frafra/Scaricati/shedskin-0.1.1/lib/re.cpp -lgc -lpcre  -o life_shed
/home/frafra/Scaricati/shedskin-0.1.1/lib/builtin.cpp:688: error:
‘uint32_t’ does not name a type
/home/frafra/Scaricati/shedskin-0.1.1/lib/builtin.cpp: In member function
‘virtual int __shedskin__::str::__hash__()’:
/home/frafra/Scaricati/shedskin-0.1.1/lib/builtin.cpp:738: error:
‘SuperFastHash’ was not declared in this scope
life_shed.cpp: In member function ‘virtual __shedskin__::tuple2<int, int>*
__life_shed__::__gen_product::next()’:
life_shed.cpp:228: error: cannot convert ‘__shedskin__::tuple2<void*,
void*>*’ to ‘__shedskin__::tuple2<int, int>*’ in return
make: *** [life_shed] Error 1

This is the output on Ubuntu Jaunty i386:
g++  -O2 -pipe -Wno-deprecated  -I. -I/usr/lib/shedskin/lib
/usr/lib/shedskin/lib/sys.cpp /usr/lib/shedskin/lib/builtin.cpp life.cpp
/usr/lib/shedskin/lib/re.cpp -lgc -lpcre  -o life
life.cpp: In member function ‘virtual __shedskin__::tuple2<int, int>*
__life__::__gen_product::next()’:
life.cpp:228: error: cannot convert ‘__shedskin__::tuple2<void*, void*>*’
to ‘__shedskin__::tuple2<int, int>*’ in return
make: *** [life] Errore 1

Here's my code. The first function (product) is a reimplementation for
shedskin of itertools.product, fully working.

I'm using shedskin 0.1.1 and no errors or warnings are visible during:
$ shedskin life_shed.py

Attachments:

GC error message "Too many heap sections" after reading big files

Issue by [email protected]
27 Jul 2009 at 2:13 GMT
Originally opened on Google Code


GC error message "Too many heap sections" after reading big files.

This happens with shedskin v0.1.1 and v0.2


OS: Win XP SP2
Shedskin version 0.2

Scenario:
Read a 6-7MB file contents into a buffer for about 40-50 times
e.g: f = open("my_big_file.bin", "rb")
     buff = f.read()
     buff.close()


A file called gc.txt is created in the current directory reporting "GC
Warning: Repated allocation of very large block..."
Given enough reads the GC crashes altogether along with the program.




f->close missing ()

Issue by [email protected]
11 Apr 2009 at 1:58 GMT
Originally opened on Google Code


ben@bds2:/tmp$ shedskin dxfpurgeblocks
*** SHED SKIN Python-to-C++ Compiler 0.1 ***
Copyright 2005-2008 Mark Dufour; License GNU GPL version 3 (See LICENSE)

[iterative type analysis..]
***
iterations: 3 templates: 312
[generating c++ code..]

ben@bds2:/tmp$ make
g++  -O2 -pipe -Wno-deprecated  -I. -I/home/ben/shedskin/shedskin-0.1/lib
/home/ben/shedskin/shedskin-0.1/lib/stat.cpp
/home/ben/shedskin/shedskin-0.1/lib/sys.cpp
/home/ben/shedskin/shedskin-0.1/lib/builtin.cpp dxfpurgeblocks.cpp
/home/ben/shedskin/shedskin-0.1/lib/os/__init__.cpp
/home/ben/shedskin/shedskin-0.1/lib/os/path.cpp
/home/ben/shedskin/shedskin-0.1/lib/re.cpp -lgc -lpcre  -lutil -o
dxfpurgeblocks
dxfpurgeblocks.cpp: In function ‘void __dxfpurgeblocks__::__init()’:
dxfpurgeblocks.cpp:216: error: statement cannot resolve address of
overloaded function
/home/ben/shedskin/shedskin-0.1/lib/os/__init__.cpp: In function ‘int
__os__::tcgetpgrp(int)’:
/home/ben/shedskin/shedskin-0.1/lib/os/__init__.cpp:630: warning:
converting to non-pointer type ‘int’ from NULL
make: *** [dxfpurgeblocks] Error 1


As you can see, shedskin completed without error.  The resulting code
failed to compile.  I fixed this by changing f->close to f->close() in the
generated dxfpurgeblocks.cpp.

re.findall not compatible with CPython

Issue by [email protected]
8 Sep 2008 at 1:45 GMT
Originally opened on Google Code


When a group is defined in a pattern, re.findall returns matches instead
the group.

e.g. 
re.findall("ab (cd) ef", "ab cd ef gh")

CPython returns: ['cd']
Shedskin executable returns: ['ab cd ef']



Shedskin verison: 0.0.28










compile shedskin or speedup with compiling of modules

Issue by Thomas Spura
23 Aug 2009 at 5:26 GMT
Originally opened on Google Code


I tried to run "shedskin shekskin"^^

In any files are "import compiler".... But only needed in one module!

This patch corrects this (tests fixes for 0.2 and 0.2.1 are currently
failing here, but with master also -> no problem (maybe another problem))

Another bug is new:

running: shedskin cpp
*** SHED SKIN Python-to-C++ Compiler 0.2 ***
Copyright 2005-2009 Mark Dufour; License GNU GPL version 3 (See LICENSE)

*ERROR* shared.py:143: function/class redefinition is not supported ('class_')

"class_" is in shared.py and in builtin.py, possibly this is resulting this
error

Attachments:

[deleted issue]

Issue by Unknown
Date unknown
Originally opened on Google Code


[deleted issue]

Support "with" statement

Issue by Jérémie Roquet
6 Jan 2010 at 10:25 GMT
Originally opened on Google Code


Hello,

It would be nice to have support for the "with" statement introduced in
 http://www.python.org/dev/peps/pep-0343/

It's available in CPython from version 2.5 (in the __future__
pseudo-module) and from version 2.6 (as a "normal" keyword).

Thanks,

input()

Issue by [email protected]
12 Jan 2009 at 1:05 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1.i type script code: a = input() 
2. when i compile i have the error unbound interfinied 'input'
3. why i have this error ? sorry for my english i'm french

What is the expected output? What do you see instead?
nothing

What version of the product are you using? On what operating system?
python 2.6 and shedskin 0.30

Please provide any additional information below.


int(x==y) fails to compile

Issue by [email protected]
6 Mar 2008 at 2:10 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. shed a python file with these contents:

if __name__=='__main__':
    print int(4==2)

2. run make

What is the expected output? What do you see instead?

expected output is successful compilation, instead I saw:

C:/Documents and Settings/user/Desktop/shedskin/shedskin-
0.0.27/shedskin/lib/builtin.hpp: In function `int __shedskin__::__int(T) 
[with T = bool]':
hmm.cpp:15:   instantiated from here
C:/Documents and Settings/user/Desktop/shedskin/shedskin-
0.0.27/shedskin/lib/builtin.hpp:74: error: base operand of `->' is not a 
pointer
make: *** [hmm.pyd] Error 1

What version of the product are you using? On what operating system?

shedskin 0.0.27
g++ 3.4.2 (mingw-special)
Windows XP SP2

Please provide any additional information below.

This is obviously a terse example of the failure.

*ERROR* fabricate.py:27: cannot locate module: atexit

Issue by [email protected]
14 Sep 2009 at 10:00 GMT
Originally opened on Google Code


# What happens:
Apparently shedskin can't find find the standard python module "atexit".

# Steps to reproduce:
1. Download fabricate from http://code.google.com/p/fabricate/
2. Place fabricate.py in the same folder as shedskin.py
3. ./shedskin.py fabricate.py

# Specifics:
Shedskin SVN revision 958
Fabricate SVN revision 48
Mac OSX 1.5.8 default Python install

sys.exit() does not allow strings

Issue by [email protected]
16 Jan 2008 at 1:31 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. import sys
2. sys.exit("Program exits")

I'm testing this on Win XP. Shedskin 0.0.26 creates the .cpp and .hpp 
files, but will not make them. Changing the string in sys.exit() to an 
int, bypasses the problem.


inheritance from builtins is not supported

Issue by [email protected]
29 Jul 2008 at 12:06 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. shedskin g_encode.py
2.
3.

What is the expected output? What do you see instead?

success.

*ERROR* g_encode.py:24: inheritance from builtins is not supported

What version of the product are you using? On what operating system?
SHED SKIN Python-to-C++ Compiler 0.0.28 ***
Ubuntu linux


Please provide any additional information below.

 The problem code is this:

class BadFormatError(RuntimeError):
        def __init__(self, *x):
                RuntimeError.__init__(self, *x)


Unfortunately, this kind of thing is essential if one is going
to do much of anything with exceptions.

type long cannot be used

Issue by [email protected]
7 Jan 2009 at 1:37 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. create a big long number in a python code
2. shedskin it
3. run the c++ code

What is the expected output? What do you see instead?
Expected output is a big long number
I get negative int numbers intead

What version of the product are you using? On what operating system?
latest as on 7 Jan 2008
WinXP SP3
Please provide any additional information below.
Possible soln:
Implement gmp.

Create shedskin package for laterly easier import/install

Issue by Thomas Spura
6 Sep 2009 at 4:01 GMT
Originally opened on Google Code


Creation of a shedskin package:

The setup.py was modified to create a execuable 'shedskin.py', that can be
symlinced to anywhere where needed. On later installs the executable will
be smaler, because the sys.path.append won't be needed at all.

Don't know what 'backward.py' and 'bert.py' are about... Can they be
ignored/deleted? They are looking like tests…

Attachments:

*ERROR* basedados.py:11: cannot locate module: psycopg2

Issue by [email protected]
9 Jul 2009 at 2:09 GMT
Originally opened on Google Code


Hi,

I have a module (basedados.py) that starts as:
"""
#-*- coding: iso-8859-15 -*-

import ConfigParser
import psycopg2
"""

It runs fine in Python, as stand-alone or when called from other modules.
If I try:
$ shedskin basedados
*** SHED SKIN Python-to-C++ Compiler 0.1.1 ***
Copyright 2005-2009 Mark Dufour; License GNU GPL version 3 (See LICENSE)

*ERROR* basedados.py:11: cannot locate module: psycopg2

Even if I remove every line from the module except the 'import psycopg2'
statement, the error is the same.

I'm using Slackware Linux 12.1, python 2.5.2 and shedskin 0.1.1

inheritance from extension class should either work or give a proper error

Issue by [email protected]
12 Dec 2009 at 12:37 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. shedskin test.py
2.
3.

What is the expected output? What do you see instead?

expected: successful compilation or an error telling me I can't do this
instead: 

Traceback (most recent call last):
  File "/lfs1/chiang/pkg/shedskin-0.2/ss.py", line 433, in <module>
    main()
  File "/lfs1/chiang/pkg/shedskin-0.2/ss.py", line 430, in main
    annotate()
  File "/lfs1/chiang/pkg/shedskin-0.2/ss.py", line 216, in annotate
    paste(callfunc.node, typesetreprnew(callfunc, inode(callfunc).parent,
False))
  File "/lfs1/chiang/pkg/shedskin-0.2/ss.py", line 163, in paste
    line = source[expr.lineno-1][:-1]
IndexError: list index out of range


What version of the product are you using? On what operating system?
0.2
Linux

Please provide any additional information below.


Attachments:

type long cannot be used

Issue by [email protected]
7 Jan 2009 at 1:38 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. create a big long number in a python code
2. shedskin it
3. run the c++ code

What is the expected output? What do you see instead?
Expected output is a big long number
I get negative int numbers intead

What version of the product are you using? On what operating system?
latest as on 7 Jan 2008
WinXP SP3
Please provide any additional information below.
Possible soln:
Implement gmp.

Reorder exceptions + add 2 new ones

Issue by Thomas Spura
23 Aug 2009 at 5:13 GMT
Originally opened on Google Code


This 2 patches add 2 new exeptions (ImportError and AttributeError), so
some more programs can be compiled...

Furthermore, while typing them in, I notice that currently e.g.
EOFException is declared twice in lib/builtin.py

With reordered according to alphabeth, that would not happened…
(-> Second patch)

What version of the product are you using? On what operating system?
trunk

Attachments:

shedskin can't deal with returning a 3-tuple

Issue by [email protected]
31 Jul 2008 at 9:27 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. shedskin foo.py # (foo.py is attached)
2. look at type annotation in foo.ss.py
3.

What is the expected output? What do you see instead?

The expected output has the return type of foo.foo() being a
dictionary.   Instead, it claims it is an iter of sequence of strings.

What version of the product are you using? On what operating system?
0.0.28 xubuntu 8.04

Please provide any additional information below.


Attachments:

Tutorial 'Generic Type' example fails to compile to extension module

Issue by [email protected]
24 Feb 2009 at 7:27 GMT
Originally opened on Google Code


What steps will reproduce the problem?
Generic Type example ( in the readme.html ) does not compile to an
extension module

What is the expected output? What do you see instead?
I'm guessing it should spit out a pyd, but instead I get:

C:\shedskin-0.1\shedskin>shedskin -e gtype_test.py
*** SHED SKIN Python-to-C++ Compiler 0.1 ***
Copyright 2005-2008 Mark Dufour; License GNU GPL version 3 (See LICENSE)

[iterative type analysis..]
***
iterations: 3 templates: 49
template <class A> class matrix
[generating c++ code..]

C:\shedskin-0.1\shedskin>make
g++  -O2 -pipe -Wno-deprecated  -I. -IC:/shedskin-0.1/shedskin/lib
-Ic:/python25
/include -D__SS_BIND gtype_test.cpp
C:/shedskin-0.1/shedskin/lib/builtin.cpp C:/
shedskin-0.1/shedskin/lib/re.cpp -lgc -lpcre  -shared -Lc:/python25/libs
-lpytho
n25 -o gtype_test.pyd
In file included from gtype_test.cpp:1:
gtype_test.hpp:41: error: expected constructor, destructor, or type
conversion b
efore '*' token
gtype_test.hpp:41: error: expected `;' before '*' token
gtype_test.cpp:34: error: using-declaration for non-member at class scope
gtype_test.cpp:34: error: expected `;' before '*' token
gtype_test.cpp: In function `PyObject* __gtype_test__::matrixNew(PyTypeObject*,
PyObject*, PyObject*)':
gtype_test.cpp:47: error: 'struct __gtype_test__::matrixObject' has no
member na
med '__ss_object'
gtype_test.cpp:47: error: `__gtype_test__::matrix' is not a type
gtype_test.cpp:48: error: 'struct __gtype_test__::matrixObject' has no
member na
med '__ss_object'
gtype_test.cpp:49: error: `matrix___init__' undeclared (first use this
function)

gtype_test.cpp:49: error: (Each undeclared identifier is reported only once for
each function it appears in.)
gtype_test.cpp: In function `void
__gtype_test__::matrixDealloc(__gtype_test__::
matrixObject*)':
gtype_test.cpp:56: error: 'struct __gtype_test__::matrixObject' has no
member na
med '__ss_object'
gtype_test.cpp: At global scope:
gtype_test.cpp:135: error: `template<class A> class __gtype_test__::matrix'
used
 without template parameters
gtype_test.cpp: In function `PyObject* __gtype_test__::__to_py__()':
gtype_test.cpp:136: error: invalid use of `this' in non-member function
gtype_test.cpp:137: error: invalid use of `this' in non-member function
gtype_test.cpp:139: error: 'struct __gtype_test__::matrixObject' has no
member n
amed '__ss_object'
gtype_test.cpp:139: error: invalid use of `this' in non-member function
gtype_test.cpp:140: error: 'struct __gtype_test__::matrixObject' has no
member n
amed '__ss_object'
gtype_test.cpp: At global scope:
gtype_test.cpp:148: error: expected constructor, destructor, or type conversion
before '*' token
gtype_test.cpp:148: error: expected `;' before '*' token
make: *** [gtype_test.pyd] Error 1

It compiles fine to an exe. Code is below for convenience

class matrix:
    def __init__(self, hop):
        self.unit = hop

m1 = matrix([1])
m2 = matrix([1.0])

hope it is helpful :)


What version of the product are you using? On what operating system?
SS 0.1, WinXP 32-bit

Please provide any additional information below.



When Integers grow big.

Issue by [email protected]
7 Oct 2009 at 1:54 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. I created this simple test.py program:

#!/usr/bin/python

suma = 0

for i in range(0,10000,2):
  suma += i

print suma

2. The output of this program is 24995000, same as the output of the
shedskin C++ compiled version of the program.

3. However, the output is not the same when the range is increased to 100000.

What is the expected output? What do you see instead?
The expected output with a 100000 iterations loop is 2499950000 as the
python program will output if you run it. The shedskin version of the
modified program shows, on the oher hand, -1795017296.

I have to say that in the first case, shedskin provided a speedup of 20X,
which was pretty nice but, in the second case, it was python who knew how
to handle the bigger value and still output the correct computation.

What version of the product are you using? On what operating system?
shedskin_0.2-0ubuntu1_all-1.deb on Ubuntu 9.04

Please provide any additional information below.
Initializing "suma" to 0.0 instead of 0 makes the output of shedskin go
from "int suma" to "double suma" but the output remains the same.

Keep up the good work,
Carlos

Use of print in function which can take two types silently produces incorrect code.

Issue by [email protected]
24 Feb 2008 at 1:47 GMT
Originally opened on Google Code


I ran shedskin SVN HEAD on the following 4 line test program, and compiled
the resulting program:

def p(msg):
    print msg
p(15)
p("hello")



The output from shedskin was as follows (and appears reasonable, as far as
I know):


*** SHED SKIN Python-to-C++ Compiler 0.0.27 ***
Copyright 2005-2008 Mark Dufour; License GNU GPL version 3 (See LICENSE)
(Please send bug reports here: [email protected])

[iterative type analysis..]
**
iterations: 2 templates: 29
template <class A> p
[generating c++ code..]



The output I expected from running the resulting "foo" program was:
15
hello

However, the actual output was:
15
134762048



I half expected shedskin to complain that this program was passing two
different types to the p() function - however, it appears to attempt to
handle this by making p into a template.  Sadly, the attempt fails because
the code produced for the print assumes that the parameter is always an
integer.

I suppose that shedskin could reasonably report an error in this case, but
it would be lovely if it could handle it correctly.  Whichever - the
current behaviour of silently producing incorrect code seems like a bug.

*args and **kwargs not supported

Issue by [email protected]
14 Sep 2008 at 5:52 GMT
Originally opened on Google Code


I saw this noted in the docs, but FWIW it's also the first thing I ran into
while trying to compile simplejson (saw it in BeautifulSoup as well).  That
might be another good test case, since it's all text processing.

http://www.undefined.org/python/

Import from package on PYTHONPATH

Issue by [email protected]
29 Jul 2008 at 12:24 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. from gmisclib import foo
2. (Package gmisclib is a pure python package of modules containing foo.
It's on the PYTHONPATH, not right here, but python has no problem finding it.)

What is the expected output? What do you see instead?

Success.
*ERROR* avio.py:5: cannot locate module: gmisclib


What version of the product are you using? On what operating system?
0.0.28 on Ubuntu

Please provide any additional information below.


dict.setdefault is not there

Issue by [email protected]
12 Oct 2009 at 3:45 GMT
Originally opened on Google Code


Hi,

here's what the dict method setdefault does:

def dict_setdefault(D, k, d):
    #D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
    r = D.get(k,d)
    if k not in D:
        D[k] = d
    return r


btw, here is another example for shedskin:
    http://rene.f0o.com/~rene/stuff/spacial_hash/hashmap.py

I converted the code from here so that it works with shedskin:
    http://entitycrisis.blogspot.com/2007/11/spatial-hashing.html


cheers,

SS can't compile resursion algorithm

Issue by [email protected]
17 Feb 2008 at 6:57 GMT
Originally opened on Google Code


Simple test case in attach.

make run                                                [22:58]
g++  -O3 -pipe -fomit-frame-pointer  -I. -I./lib ./lib/builtin.cpp sort.cpp
-lgc  -o sort
sort.cpp: In function ‘__shedskin__::list<void*>*
__sort__::quicksort(__shedskin__::list<int>*)’:
sort.cpp:64: error: no matching function for call to
‘__shedskin__::list<void*>::__add__(__shedskin__::list<int>*)’
./lib/builtin.hpp:1478: note: candidates are: __shedskin__::list<T>*
__shedskin__::list<T>::__add__(__shedskin__::list<T>*) [with T = void*]
make: *** [sort] Ошибка 1

Attachments:

error: integer constant is too large for "long" type

Issue by [email protected]
3 Mar 2009 at 7:34 GMT
Originally opened on Google Code


Apologies in advance if this is my ignorance!  And thank you for producing
such a great product.

I came across this problem trying to solve problem 234 of the euler
project.  The issue seems to be one of converting the python "long" type
into a C++ type that will handle very large integers.

What steps will reproduce the problem?

I created the following code in python:
************************************************
from time import time

def isPrime(n):
    """tests the primality of n the hard way (instead of sympy's
    isprime)"""
    if n==1:
        return 0
    elif n<=3:
        return 1
    if n%2==0:
        return 0
    for i in range(3,int(n**(0.5))+1,2):
        if n%i==0:
            return 0
    return 1

startTime=time()
myN= 1000000000L  #probably need SWIG/shed skin to do this...

i=0L
myPs=[2L]
for i in range(3,int(myN**0.5)+1,2):
    if isPrime(i):
        myPs.append(i)
i+=2
while not isPrime(i):
    i+=2
myPs.append(i)
print "Primes generated up to",max(myPs)


mySD=0L
i=0L
k=0L
lps=0L
ups=0L
while 1:
    lps=myPs[i]
    ups=myPs[i+1]
    for k in xrange(lps**2+1,ups**2):
        if k>myN: break
        divs=0
        if k%lps==0: divs+=1
        if k%ups==0: divs+=1
        if divs==1: mySD+=k
    if k>myN: break
    i+=1

print "the sum of semidivs not exceeding",myN,"is",mySD

finishTime=time()
print "time taken: %f" %(finishTime-startTime)
*****************************************************

For myN=1000000L it seems to work fine (answer agrees with python, and runs
in a tenth of the time)

For myN=10000000L it produces a negative answer for a sum of large positive
numbers, without producing any errors or warnings, suggesting that the
integer has "ticked over" to a negative number.  Similar results up to
myN=1000000000L.  The expected output is a large positive integer.

For myN=999966663333L it produces the error in the title.


What version of the product are you using? On what operating system?
I'm running Skin Shed 0.1 (downloaded 3 Mar 2009) with Windows XP.

Please provide any additional information below.

many thanks

Please change the license from GPL to LGPL.

Issue by ludolph%[email protected]
8 Oct 2009 at 6:51 GMT
Originally opened on Google Code


It's GPL. And when you compile python code with shedskin, it links against
shedskin's minimal python lib implementation. Which means whatever you
compile with shedskin must become GPL. 

This will be problematic for anyone that wants to use this application in a
commercial environment or code that is already licensed under a license
that is not GPL compatible. 

If the code is LPGL changes to shedskin must still get open sourced(LGPL
compatible license) but the code that gets linked to the shedskin
supporting python library can be any license.

Ps: Also have a look at
http://www.reddit.com/r/programming/comments/9rtsb/shedskin_an_experimental_pyth
on_to_c_compiler/

mingw restriction overly harsh

Issue by [email protected]
21 Oct 2009 at 7:45 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. presence of c:/mingw on Windows XP Pro
2. shedskin test.py
3.

What is the expected output? What do you see instead?
...    *ERROR* please rename or remove c:/mingw, as it conflicts with Shed Skin


What version of the product are you using? On what operating system?
2.0 or shedskin-read-only checkout.  Windows XP Pro

Please provide any additional information below.

User should not have to uninstall a perfectly good mingw compiler. Just
check that it's not currently on the path.

Patch against shedskin-read-only is attached. [Works for me]

Attachments:

Compilation on Mac OS X...possible solution

Issue by [email protected]
16 Jan 2008 at 2:29 GMT
Originally opened on Google Code


I only tested the solution on the test.py, but that works.

What steps will reproduce the problem?
1. Install shedskin, local directory
2. ./shedskin test.py
3. make
4. ./test

What is the expected output? What do you see instead?

Python->C++ works:

glop-/Users/bblais/Desktop/shedskin-0.0.26-> ./shedskin test.py
*** SHED SKIN Python-to-C++ Compiler 0.0.26 ***
Copyright 2005-2008 Mark Dufour; License GNU GPL version 3 (See LICENSE)
(Please send bug reports here: [email protected])

[iterative type analysis..]
**
iterations: 2 templates: 25
[generating c++ code..]
==========

compilation works:

glop-/Users/bblais/Desktop/shedskin-0.0.26-> make
g++  -O3 -s -pipe -fomit-frame-pointer  
-I/Users/bblais/Desktop/shedskin-0.0.26/lib 
/Users/bblais/Desktop/shedskin-0.0.26/lib/builtin.cpp test.cpp -lgc  -o test

===========
Running doesn't:

glop-/Users/bblais/Desktop/shedskin-0.0.26-> ./test
dyld: lazy symbol binding failed: lazy pointer not found
dyld: lazy pointer not found
zsh: trace trap  ./test



What version of the product are you using? On what operating system?

OS X 10.4 (Tiger)

Please provide any additional information below.

 Solution, for at least this file, is to remove the -s option and run strip manually, in Makefile:

CCFLAGS=-O3 -pipe -fomit-frame-pointer $(CPPFLAGS) 
-I/Users/bblais/Desktop/shedskin-
0.0.26/lib

test:   $(CPPFILES) $(HPPFILES)
    $(CC) $(CCFLAGS) $(CPPFILES) $(LFLAGS) -o test
    strip test




time.sleep() 100% cpu in Windows

Issue by [email protected]
19 Feb 2009 at 4:14 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. Create a script that uses time.sleep()
2. shedskin.bat <script>; make
3. Monitor CPU utilization of the script

What version of the product are you using? On what operating system?
0.1 on Windows XP

operator module

Issue by [email protected]
8 Jan 2010 at 7:06 GMT
Originally opened on Google Code


I noticed a lack of an operator module, so I decided to write a basic 
one...

def add(a, b):
    return a + b

def sub(a, b):
    return a - b

def mul(a, b):
    return a * b

def div(a, b):
    return a / b

def floordiv(a, b):
    return int(a / b)

def truediv(a, b):
    # no easy way to implement truediv in 2.6.
    return a.__truediv__(b)

def and_(a, b):
    return a and b

def or_(a, b):
    return a or b

def not_(a):
    return not a

def inv_(a, b):
    return ~a

__add__ = add
__sub__ = sub
__mul__ = mul
__div__ = div
__floordiv__ = floordiv
__truediv__ = truediv
__and__ = and_
__or__ = or_
__not__ = not_
__inv__ = inv_

I got an error while trying to compile it though.

thomas@kamikaze:~/shedskin/lib$ python ../ss.py operator.py 
*** SHED SKIN Python-to-C++ Compiler 0.2 ***
Copyright 2005-2009 Mark Dufour; License GNU GPL version 3 (See LICENSE)

Traceback (most recent call last):
  File "../ss.py", line 433, in <module>
    main()
  File "../ss.py", line 428, in main
    analysis(name)
  File "../ss.py", line 51, in analysis
    getgx().main_module = parse_module(getgx().main_mod, ast)
  File "/home/thomas/shedskin/graph.py", line 1428, in parse_module
    mv.dispatch(mod.ast)
  File "/home/thomas/shedskin/graph.py", line 54, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.6/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/thomas/shedskin/graph.py", line 248, in visitModule
    self.visit(n)
  File "/home/thomas/shedskin/graph.py", line 54, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.6/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/thomas/shedskin/graph.py", line 384, in visitFrom
    mod = self.importmodules(node.modname, node, True)
  File "/home/thomas/shedskin/graph.py", line 360, in importmodules
    mod = self.importmodule(subname, subname, node, fake)
  File "/home/thomas/shedskin/graph.py", line 367, in importmodule
    mod = self.analyzeModule(name, pseudonym, node, fake)
  File "/home/thomas/shedskin/graph.py", line 421, in analyzeModule
    mod = parse_module(name, None, getmv().module, node)
  File "/home/thomas/shedskin/graph.py", line 1428, in parse_module
    mv.dispatch(mod.ast)
  File "/home/thomas/shedskin/graph.py", line 54, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.6/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/thomas/shedskin/graph.py", line 242, in visitModule
    self.visit(Class(dummy, [], None, Pass()))
  File "/home/thomas/shedskin/graph.py", line 54, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.6/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/thomas/shedskin/graph.py", line 1166, in visitClass
    if not getmv().module.builtin and not node in getmv().classnodes:
AttributeError: moduleVisitor instance has no attribute 'classnodes'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 39, 
in apport_excepthook
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python2.6/dist-packages/apport/__init__.py", line 1, in 
<module>
    from apport.report import Report
  File "/usr/lib/python2.6/dist-packages/apport/report.py", line 14, in 
<module>
    import subprocess, tempfile, os.path, urllib, re, pwd, grp, os, sys
  File "/usr/lib/python2.6/subprocess.py", line 430, in <module>
    import pickle
  File "/usr/lib/python2.6/pickle.py", line 827, in <module>
    class Unpickler:
  File "/usr/lib/python2.6/pickle.py", line 957, in Unpickler
    def load_binfloat(self, unpack=struct.unpack):
AttributeError: 'module' object has no attribute 'unpack'

Original exception was:
Traceback (most recent call last):
  File "../ss.py", line 433, in <module>
    main()
  File "../ss.py", line 428, in main
    analysis(name)
  File "../ss.py", line 51, in analysis
    getgx().main_module = parse_module(getgx().main_mod, ast)
  File "/home/thomas/shedskin/graph.py", line 1428, in parse_module
    mv.dispatch(mod.ast)
  File "/home/thomas/shedskin/graph.py", line 54, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.6/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/thomas/shedskin/graph.py", line 248, in visitModule
    self.visit(n)
  File "/home/thomas/shedskin/graph.py", line 54, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.6/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/thomas/shedskin/graph.py", line 384, in visitFrom
    mod = self.importmodules(node.modname, node, True)
  File "/home/thomas/shedskin/graph.py", line 360, in importmodules
    mod = self.importmodule(subname, subname, node, fake)
  File "/home/thomas/shedskin/graph.py", line 367, in importmodule
    mod = self.analyzeModule(name, pseudonym, node, fake)
  File "/home/thomas/shedskin/graph.py", line 421, in analyzeModule
    mod = parse_module(name, None, getmv().module, node)
  File "/home/thomas/shedskin/graph.py", line 1428, in parse_module
    mv.dispatch(mod.ast)
  File "/home/thomas/shedskin/graph.py", line 54, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.6/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/thomas/shedskin/graph.py", line 242, in visitModule
    self.visit(Class(dummy, [], None, Pass()))
  File "/home/thomas/shedskin/graph.py", line 54, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.6/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/thomas/shedskin/graph.py", line 1166, in visitClass
    if not getmv().module.builtin and not node in getmv().classnodes:
AttributeError: moduleVisitor instance has no attribute 'classnodes'

Uncaught KeyError when compiling

Issue by [email protected]
14 Sep 2008 at 5:28 GMT
Originally opened on Google Code


I am trying to compile BeautifulSoup and therefore sgmllib.py and then
markupbase.py (the latter 2 from the Python standard lib).

With some modifications I can get markupbase.py to generate C++ code. 
However I couldn't get past this with sgmllib -- not sure what the problem is.

Attached is the diff of all 3 files.   BeautifulSoup is a very useful
library, it's a bit slow, and it's all text processing, so I think it would
make a very good test case for shedskin.  (Great project BTW!)

There are some other bugs I encountered as well (which you can see in the
diffs):

- RuntimeError not supported
- self.foo is not like self.__class__.foo as it is in Python
- *args not supported
- from __future__ import generators not supported (it would be nice to just
ignore this or something, a lot of code has it for compatibility)


shedskin-read-only$ ./shedskin sgmllib.py
*** SHED SKIN Python-to-C++ Compiler 0.0.29 ***
Copyright 2005-2008 Mark Dufour; License GNU GPL version 3 (See LICENSE)
(Please send bug reports here: [email protected])

Traceback (most recent call last):
  File "/home/andy/svn/shedskin-read-only/ss.py", line 482, in <module>
    main()
  File "/home/andy/svn/shedskin-read-only/ss.py", line 477, in main
    analysis(name)
  File "/home/andy/svn/shedskin-read-only/ss.py", line 81, in analysis
    gx.main_module = parse_module(gx.main_mod, ast)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 1540, in parse_module
    mv.dispatch(mod.ast)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 56, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.5/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 324, in visitModule
    self.visitFunction(func_copy, cl, inherited_from=ancestor)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 484, in visitFunction
    self.visit(node.code, func)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 56, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.5/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 241, in visitStmt
    self.visit(b, func)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 56, in dispatch
    ASTVisitor.dispatch(self, node, *args)
  File "/usr/lib/python2.5/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 1118, in visitAssign
    self.tuple_flow(lvalue, rvalue, func)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 1172, in tuple_flow
    tvar = self.tempvar(lvalue, func)
  File "/home/andy/svn/shedskin-read-only/graph.py", line 790, in tempvar
    varname = self.tempcount[getgx().parent_nodes[node]]
KeyError: AssTuple([AssName('sectName', 'OP_ASSIGN'), AssName('j',
'OP_ASSIGN')])

Attachments:

Shedskin Accepts Function Objects In Containers, But Output tDoesn't Compile

Issue by seun.osewa
31 Jul 2009 at 12:08 GMT
Originally opened on Google Code


What steps will reproduce the problem?
1. Run the attached file "test.py" with python. It prints "0" or "100"
2. Generate a C++ file with Shedskin. "shedskin test.py"  It works
3. Try to compile the resulting file "make".  It doesn't compile.

What is the expected output? What do you see instead?
The included g++ throws out various type errors in builtin.hpp.

What version of the product are you using? On what operating system?
Shedskin 0.2 on Windows.

Please provide any additional information below.
The type inference seems to fail only when function objects are stored in
containers.  (Things works as expected when function objects are stored in
variables.)

Attachments:

random generator missing bits in constant

Issue by [email protected]
28 Jan 2008 at 3:50 GMT
Originally opened on Google Code


The results of random are not bit-identical between the Python interpreter
and compiled code.   Only the lowest order bits are affected - the
difference is not visible with the default floating point output precision.

In lib/random.cpp, line 205

    return (((a*67108864.0)+b)*(1.0/9.00719925474e+15));

This line should be (see Python 2.5.1 source, _randommodule.c)

    return (((a*67108864.0)+b)*(1.0/9007199254740992.0));

The following program will demonstrate the issue (need to hack the
generated cpp to see the full precision).

import random

random.seed(123)
r = random.uniform(-1.0,1.0)

#print "%20.16"%r
print repr(r)










Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.