Releases: TranscryptOrg/Transcrypt
ES6 modules and PY3.7 dataclasses incl. inheritance, REQUIRES PYTHON 3.7
-
Dataclasses can now inherit from other dataclasses. Inheritance between dataclasses and ordinary classes is left out because it introduces overhead in all classes and in CPython lacks a proper method to call the parents
__init__
before a generated__init__
, which makes it hardly worthwhile. -
The dataclasses testlet shows some of the possibilities:
from dataclasses import dataclass from typing import ClassVar def getQ (): return 1002 @dataclass class A: m = 101010 n: int = 202020 @dataclass class B (A): p: int = 1001 q: int = 1002 @dataclass (order = True) class C (B): @dataclass class CC (B): k: int = 40 l: float = 55.5 j = 60 x: ClassVar = 10 y: int = 20 yy: int = 22 z: int = 30 zz: int = 33 t: ClassVar = 40 g = 100000 h = 100001 i = 100002 def getV (self): return 3 def setV (self, value): pass v = property (getV, setV) def getW (self): return 4 def setW (self, value): pass w: int = property (getW, setW) def f (self, p, autoTester): self.a = p self.b = 2000 autoTester.check (self.x, self.y, self.a) return f'something(a: {self.a}, b: {self.b})' @dataclass (order = True) class D: _p: int = 3 def setP (self, value): pass #self._p = value def getP (self): return 20 #return self._p p: int = property (getP, setP) def run (autoTester): c = C (y = 200, zz = 330) cc = C (y = 10200) c.f (123, autoTester) c.t = 400 cc.f (456, autoTester) cc.t = 4000 for obj in c, cc: autoTester.check (obj.x, obj.y, obj.yy, obj.z, obj.zz, obj.t, obj.a, obj.b) autoTester.check (repr (c)) autoTester.check (repr (cc)) #__pragma__ ('opov') autoTester.check (c == cc) autoTester.check (c != cc) autoTester.check (c < cc) autoTester.check (c > cc) # autoTester.check (c <= cc) # autoTester.check (c >= cc) autoTester.check (c == c) autoTester.check (c != c) autoTester.check (c < c) autoTester.check (c > c) autoTester.check (c <= c) autoTester.check (c >= c) d3 = D () d1 = D () d2 = D () autoTester.check (repr (d1)) autoTester.check (d3, d1, d3 > d1) autoTester.check (d2, d1, d2 > d1) autoTester.check (d3, d2, d3 > d2) ccc = C.CC () autoTester.check (ccc.n, ccc.p, ccc.q, ccc.k, ccc.l)
Output both in CPython and Transcrypt is:
- Code for property decorators has been slightly refactored
ES6 modules and PY3.7 dataclasses, REQUIRES PYTHON 3.7
Most functionality of the production release is present.
Some minor changes are to be expected to achieve better interop with webpack.
All local tests pass.
N.B. This release requires Python 3.7.0b3 or higher.
Following code now functions correctly:
from dataclasses import dataclass
from typing import ClassVar
@dataclass (order = True)
class C:
x: ClassVar = 10
y: int = 20
yy: int = 22
z: int = 30
zz: int = 33
t: ClassVar = 40
def f (self, p, autoTester):
self.a = p
self.b = 2000
autoTester.check (self.x, self.y, self.a)
return f'something(a: {self.a}, b: {self.b})'
def run (autoTester):
c = C (y = 200, zz = 330)
cc = C (y = 10200)
c.f (123, autoTester)
c.t = 400
cc.f (456, autoTester)
cc.t = 4000
for obj in c, cc:
autoTester.check (obj.x, obj.y, obj.yy, obj.z, obj.zz, obj.t, obj.a, obj.b)
autoTester.check (c.__repr__ ())
autoTester.check (cc.__repr__ ())
#__pragma__ ('opov')
autoTester.check (c == cc)
autoTester.check (c != cc)
autoTester.check (c < cc)
autoTester.check (c > cc)
autoTester.check (c <= cc)
autoTester.check (c >= cc)
autoTester.check (c == c)
autoTester.check (c != c)
autoTester.check (c < c)
autoTester.check (c > c)
autoTester.check (c <= c)
autoTester.check (c >= c)
ES6 modules early experience
Docs not yet adapted.
All of the shipment tests should run correctly.
Take a look at the html files of the demo to see how modules are used by them.
To install:
-
Add the directory containing run_transcrypt.bat to the system path (search path) of your OS
-
On the command line, use:
run_transcrypt -b demo (SO NO . py EXTENSION !!)
rather than:
run_transcrypt -b demo.py (As used to be the case)
This is because the main module can now also be a JS-only module.
The compiler just looks what's there.
Compilation units suitable to create pure JS components that can be combined and distributed without Transcrypt being present.
It is now possible to create native JavaScript component frameworks using Transcrypt. Components can be freely mixed on a page without requiring recompilation. A developer doesn't need Transcrypt or any knowledge of it to use such a framework. Each page has one unit that contains the Transcrypt runtime and, if needed, any central facilities. It is compiled with the -u .run switch. In addition each page can hold as many separate components as needed. Compile these with the -u .com switch. A loader is generated, accepting a list of components. By varying this list, each page can have it's own subset of components, without the need to recompile. The generated JavaScript code for components can be very small, typically a few hundred bytes. The runtime and central facilities are included in the page only once.
See:
Property decorators a.o.
This is an experimental release.
Paris (PyPi v3.6.4, GitHub #14): Support for Python 3.6, div. fixes and enhancements
Version 'Paris' of Transcrypt is the first release to run with Python 3.6.
Compatibility with Python 3.5 is retained.
New features:
- regular expresson module ready
- globals () ready
- one page can now hold multiple Transcrypt apps
- demo for cyclejs added
- 'yield from' now supported
- autotest GUI improved
-Travis continuous integration tests for Python 3.5, 3.6, nightly added - fstrings (without formatting mini-language) (Python 3.6 only)
- dashed numbers (Python 3.6 only)
- nested and function-local classes
- metaclasses with overridable new operator
- getattr, setattr
- many fixes and enhancements.
Thanks for all invested time and many great contributions!
Paris (PyPi v3.6.1, GitHub #13): Partial support for Python 3.6
Version 'Paris' of Transcrypt is the first release to run with Python 3.6.
Compatibility with Python 3.5 is retained.
New features:
- fstrings (without formatting mini-language) (Python 3.6 only)
- dashed numbers (Python 3.6 only)
- nested and function-local classes
- metaclasses with overridable new operator
- getattr, setattr
- many fixes and enhancements.
Thanks for all good ideas, careful feedback and clever solutions contributed!
Release: Bugfix for Athens + plotly demo (PyPi v3.5.229, GitHub #12)
Release: Bugfix for Athens (PyPi v3.5.227, GitHub #11
- Fix for item #118 Unexpected indent when rebuilding
Release: Bugfix for Athens (PyPi v3.5.223, GitHub #10)
- Fix for 'cannot import symbols' bug when using -r with autotest.
- Exception hierarchy improved, all Transcrypt runtime exceptions now derive from Exception
- Non-standard attribute 'stack' added to Exception to obtain stack trace in def-facto JavaScript compatible way
- Attempt to iterate over non-iterable now results in exception (only when using -e 6 switch) (see issue #112))
- Iterating over TypedArrays and other non-list iterables fixed (only needed for when using -e 6 switch) (see issue #112)