problem with fcall __pragma__

Open
#819 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, python

Research direction

Start by reproducing the reported __pragma__ ('fcall') benchmarks in the stated Linux, Python 3.9.6, Transcrypt 3.9.0, and Chrome environment, then inspect the generated JavaScript for update and update_count. The fix is done when the update method uses the py_update alias correctly and the generated behavior matches the intended fcall handling without the reported slowdown.

Written by the indexing model from the issue text.

Description

Discovered an issue with __pragma__ ('fcall') when a method is an alias identifier such as update. Using fcall pragma, update_count method performance increased 16% (to 24% after 4M calls), whereas update method performance decreased 2-fold.

class Cls:
    def __init__(self):
        self.count = count
    def update_count(self):
        self.count += 1
cls = Cls()

without __pragma__ ('fcall'):
loop of 1M calls:
1M cls.update_count calls: 0.268s
loop * 4:
1M cls.update_count calls: 0.240s

with __pragma__ ('fcall'):
loop of 1M calls:
1M cls.update_count calls: 0.226s
loop * 4:
1M cls.update_count calls: 0.203s

class Cls:
    def __init__(self):
        self.count = count
    def update(self):
        self.count += 1
cls = Cls()

without __pragma__ ('fcall'):
loop of 1M calls:
1M cls.update calls: 0.258s
loop * 4:
1M cls.update calls: 0.242s

with __pragma__ ('fcall'):
loop of 1M calls:
1M cls.update calls: 0.516s
loop * 4:
1M cls.update calls: 0.528s

The issue is due to incorrectly handling update, which should be aliased py_update. The JS code for the methods with fcall pragma:

update_count method (last arg is 'update_count'):

get update_count () {return __get__ (this, function (self) {
	self.count++;
}, 'update_count');}

update method (last arg is 'update', should be 'py_update'):

get py_update () {return __get__ (this, function (self) {
	self.count++;
}, 'update');}

Environment:
Linux
Python 3.9.6
Transcrypt 3.9.0
Chrome

Dominant language
Python
Stars
2.9k
Forks
218
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TranscryptOrg/Transcrypt

All issues in TranscryptOrg/Transcrypt

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.