{"action":"created","comment":{"url":"https://api.github.com/repos/nio-blocks/simulator/pulls/comments/27973462","id":27973462,"diff_hunk":"@@ -19,36 +22,32 @@ def __init__(self):\n         super().__init__()\n         self.cur_count = 0\n         self.count_lock = Lock()\n+        self._lasti = 0\n+        self.range = None\n \n     def configure(self, context):\n         super().configure(context)\n-        # Initialize our count to the starting value\n-        self.cur_count = self.attr_value.start\n+        self._lasti = 0\n+        self.range = range(self.attr_value.start, self.attr_value.end + 1,\n+                           self.attr_value.step)\n \n     def generate_signals(self, n=1):\n-        return [self._get_next_signal() for i in range(n)]\n-\n-    def _get_next_signal(self):\n-        \"\"\" Get the next signal we want to emit.\n-\n-        This will update the cur_count and return a Signal with the current\n-        count at the time the function was called.\n-        \"\"\"\n+        # bring variables into local space for minor speedup\n         with self.count_lock:\n-            # store the current count, then increment it\n-            my_count = self.cur_count\n-            self._bump_count()\n-\n-        return Signal({\n-            self.attr_name: my_count\n-        })\n-\n-    def _bump_count(self):\n-        \"\"\" Increment the current count, roll over if necessary.\n-\n-        Returns:\n-            None: self.cur_count gets updated instead\n-        \"\"\"\n-        self.cur_count += self.attr_value.step\n-        if self.cur_count > self.attr_value.end:\n-            self.cur_count = self.attr_value.start\n+            S = Signal\n+            myrange = self.range\n+            rlen = len(myrange)\n+\n+            ranges = []\n+            sigs = 0\n+            # this is how much is left of the previously used range\n+            lasti = self._lasti\n+            while sigs < n:\n+                r = myrange[lasti: lasti + (n - sigs)]\n+                lasti = len(r) % rlen\n+                sigs += len(r)\n+                ranges.append(r)\n+            assert sigs == n","path":"generators/counter.py","position":70,"original_position":70,"commit_id":"e97f9a0939df11a9d77e140d88a08fd2db1e14e6","original_commit_id":"e97f9a0939df11a9d77e140d88a08fd2db1e14e6","user":{"login":"cloudformdesign","id":5587659,"avatar_url":"https://avatars.githubusercontent.com/u/5587659?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudformdesign","html_url":"https://github.com/cloudformdesign","followers_url":"https://api.github.com/users/cloudformdesign/followers","following_url":"https://api.github.com/users/cloudformdesign/following{/other_user}","gists_url":"https://api.github.com/users/cloudformdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudformdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudformdesign/subscriptions","organizations_url":"https://api.github.com/users/cloudformdesign/orgs","repos_url":"https://api.github.com/users/cloudformdesign/repos","events_url":"https://api.github.com/users/cloudformdesign/events{/privacy}","received_events_url":"https://api.github.com/users/cloudformdesign/received_events","type":"User","site_admin":false},"body":"it was for my own sanity checking and it will be removed on the next commit. Thanks!","created_at":"2015-04-08T14:19:21Z","updated_at":"2015-04-08T14:19:21Z","html_url":"https://github.com/nio-blocks/simulator/pull/12#discussion_r27973462","pull_request_url":"https://api.github.com/repos/nio-blocks/simulator/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/nio-blocks/simulator/pulls/comments/27973462"},"html":{"href":"https://github.com/nio-blocks/simulator/pull/12#discussion_r27973462"},"pull_request":{"href":"https://api.github.com/repos/nio-blocks/simulator/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/nio-blocks/simulator/pulls/12","id":32815576,"html_url":"https://github.com/nio-blocks/simulator/pull/12","diff_url":"https://github.com/nio-blocks/simulator/pull/12.diff","patch_url":"https://github.com/nio-blocks/simulator/pull/12.patch","issue_url":"https://api.github.com/repos/nio-blocks/simulator/issues/12","number":12,"state":"open","locked":false,"title":"Speedup","user":{"login":"cloudformdesign","id":5587659,"avatar_url":"https://avatars.githubusercontent.com/u/5587659?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudformdesign","html_url":"https://github.com/cloudformdesign","followers_url":"https://api.github.com/users/cloudformdesign/followers","following_url":"https://api.github.com/users/cloudformdesign/following{/other_user}","gists_url":"https://api.github.com/users/cloudformdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudformdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudformdesign/subscriptions","organizations_url":"https://api.github.com/users/cloudformdesign/orgs","repos_url":"https://api.github.com/users/cloudformdesign/repos","events_url":"https://api.github.com/users/cloudformdesign/events{/privacy}","received_events_url":"https://api.github.com/users/cloudformdesign/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-07T23:22:32Z","updated_at":"2015-04-08T14:19:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d0abd5d1d26143ebeaa74accb4f017402280515","assignee":{"login":"cloudformdesign","id":5587659,"avatar_url":"https://avatars.githubusercontent.com/u/5587659?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudformdesign","html_url":"https://github.com/cloudformdesign","followers_url":"https://api.github.com/users/cloudformdesign/followers","following_url":"https://api.github.com/users/cloudformdesign/following{/other_user}","gists_url":"https://api.github.com/users/cloudformdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudformdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudformdesign/subscriptions","organizations_url":"https://api.github.com/users/cloudformdesign/orgs","repos_url":"https://api.github.com/users/cloudformdesign/repos","events_url":"https://api.github.com/users/cloudformdesign/events{/privacy}","received_events_url":"https://api.github.com/users/cloudformdesign/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/nio-blocks/simulator/pulls/12/commits","review_comments_url":"https://api.github.com/repos/nio-blocks/simulator/pulls/12/comments","review_comment_url":"https://api.github.com/repos/nio-blocks/simulator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nio-blocks/simulator/issues/12/comments","statuses_url":"https://api.github.com/repos/nio-blocks/simulator/statuses/e97f9a0939df11a9d77e140d88a08fd2db1e14e6","head":{"label":"nio-blocks:speedup","ref":"speedup","sha":"e97f9a0939df11a9d77e140d88a08fd2db1e14e6","user":{"login":"nio-blocks","id":7684467,"avatar_url":"https://avatars.githubusercontent.com/u/7684467?v=3","gravatar_id":"","url":"https://api.github.com/users/nio-blocks","html_url":"https://github.com/nio-blocks","followers_url":"https://api.github.com/users/nio-blocks/followers","following_url":"https://api.github.com/users/nio-blocks/following{/other_user}","gists_url":"https://api.github.com/users/nio-blocks/gists{/gist_id}","starred_url":"https://api.github.com/users/nio-blocks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nio-blocks/subscriptions","organizations_url":"https://api.github.com/users/nio-blocks/orgs","repos_url":"https://api.github.com/users/nio-blocks/repos","events_url":"https://api.github.com/users/nio-blocks/events{/privacy}","received_events_url":"https://api.github.com/users/nio-blocks/received_events","type":"Organization","site_admin":false},"repo":{"id":27410019,"name":"simulator","full_name":"nio-blocks/simulator","owner":{"login":"nio-blocks","id":7684467,"avatar_url":"https://avatars.githubusercontent.com/u/7684467?v=3","gravatar_id":"","url":"https://api.github.com/users/nio-blocks","html_url":"https://github.com/nio-blocks","followers_url":"https://api.github.com/users/nio-blocks/followers","following_url":"https://api.github.com/users/nio-blocks/following{/other_user}","gists_url":"https://api.github.com/users/nio-blocks/gists{/gist_id}","starred_url":"https://api.github.com/users/nio-blocks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nio-blocks/subscriptions","organizations_url":"https://api.github.com/users/nio-blocks/orgs","repos_url":"https://api.github.com/users/nio-blocks/repos","events_url":"https://api.github.com/users/nio-blocks/events{/privacy}","received_events_url":"https://api.github.com/users/nio-blocks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nio-blocks/simulator","description":"A library of simulators as well as a framework for creating new types of signal simulators.","fork":false,"url":"https://api.github.com/repos/nio-blocks/simulator","forks_url":"https://api.github.com/repos/nio-blocks/simulator/forks","keys_url":"https://api.github.com/repos/nio-blocks/simulator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nio-blocks/simulator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nio-blocks/simulator/teams","hooks_url":"https://api.github.com/repos/nio-blocks/simulator/hooks","issue_events_url":"https://api.github.com/repos/nio-blocks/simulator/issues/events{/number}","events_url":"https://api.github.com/repos/nio-blocks/simulator/events","assignees_url":"https://api.github.com/repos/nio-blocks/simulator/assignees{/user}","branches_url":"https://api.github.com/repos/nio-blocks/simulator/branches{/branch}","tags_url":"https://api.github.com/repos/nio-blocks/simulator/tags","blobs_url":"https://api.github.com/repos/nio-blocks/simulator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nio-blocks/simulator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nio-blocks/simulator/git/refs{/sha}","trees_url":"https://api.github.com/repos/nio-blocks/simulator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nio-blocks/simulator/statuses/{sha}","languages_url":"https://api.github.com/repos/nio-blocks/simulator/languages","stargazers_url":"https://api.github.com/repos/nio-blocks/simulator/stargazers","contributors_url":"https://api.github.com/repos/nio-blocks/simulator/contributors","subscribers_url":"https://api.github.com/repos/nio-blocks/simulator/subscribers","subscription_url":"https://api.github.com/repos/nio-blocks/simulator/subscription","commits_url":"https://api.github.com/repos/nio-blocks/simulator/commits{/sha}","git_commits_url":"https://api.github.com/repos/nio-blocks/simulator/git/commits{/sha}","comments_url":"https://api.github.com/repos/nio-blocks/simulator/comments{/number}","issue_comment_url":"https://api.github.com/repos/nio-blocks/simulator/issues/comments{/number}","contents_url":"https://api.github.com/repos/nio-blocks/simulator/contents/{+path}","compare_url":"https://api.github.com/repos/nio-blocks/simulator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nio-blocks/simulator/merges","archive_url":"https://api.github.com/repos/nio-blocks/simulator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nio-blocks/simulator/downloads","issues_url":"https://api.github.com/repos/nio-blocks/simulator/issues{/number}","pulls_url":"https://api.github.com/repos/nio-blocks/simulator/pulls{/number}","milestones_url":"https://api.github.com/repos/nio-blocks/simulator/milestones{/number}","notifications_url":"https://api.github.com/repos/nio-blocks/simulator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nio-blocks/simulator/labels{/name}","releases_url":"https://api.github.com/repos/nio-blocks/simulator/releases{/id}","created_at":"2014-12-02T01:55:26Z","updated_at":"2015-04-07T23:22:00Z","pushed_at":"2015-04-08T14:03:46Z","git_url":"git://github.com/nio-blocks/simulator.git","ssh_url":"git@github.com:nio-blocks/simulator.git","clone_url":"https://github.com/nio-blocks/simulator.git","svn_url":"https://github.com/nio-blocks/simulator","homepage":"","size":300,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"base":{"label":"nio-blocks:master","ref":"master","sha":"e64fca0de7e44eea48a9aaf1e84fb5b80eafbe7b","user":{"login":"nio-blocks","id":7684467,"avatar_url":"https://avatars.githubusercontent.com/u/7684467?v=3","gravatar_id":"","url":"https://api.github.com/users/nio-blocks","html_url":"https://github.com/nio-blocks","followers_url":"https://api.github.com/users/nio-blocks/followers","following_url":"https://api.github.com/users/nio-blocks/following{/other_user}","gists_url":"https://api.github.com/users/nio-blocks/gists{/gist_id}","starred_url":"https://api.github.com/users/nio-blocks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nio-blocks/subscriptions","organizations_url":"https://api.github.com/users/nio-blocks/orgs","repos_url":"https://api.github.com/users/nio-blocks/repos","events_url":"https://api.github.com/users/nio-blocks/events{/privacy}","received_events_url":"https://api.github.com/users/nio-blocks/received_events","type":"Organization","site_admin":false},"repo":{"id":27410019,"name":"simulator","full_name":"nio-blocks/simulator","owner":{"login":"nio-blocks","id":7684467,"avatar_url":"https://avatars.githubusercontent.com/u/7684467?v=3","gravatar_id":"","url":"https://api.github.com/users/nio-blocks","html_url":"https://github.com/nio-blocks","followers_url":"https://api.github.com/users/nio-blocks/followers","following_url":"https://api.github.com/users/nio-blocks/following{/other_user}","gists_url":"https://api.github.com/users/nio-blocks/gists{/gist_id}","starred_url":"https://api.github.com/users/nio-blocks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nio-blocks/subscriptions","organizations_url":"https://api.github.com/users/nio-blocks/orgs","repos_url":"https://api.github.com/users/nio-blocks/repos","events_url":"https://api.github.com/users/nio-blocks/events{/privacy}","received_events_url":"https://api.github.com/users/nio-blocks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nio-blocks/simulator","description":"A library of simulators as well as a framework for creating new types of signal simulators.","fork":false,"url":"https://api.github.com/repos/nio-blocks/simulator","forks_url":"https://api.github.com/repos/nio-blocks/simulator/forks","keys_url":"https://api.github.com/repos/nio-blocks/simulator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nio-blocks/simulator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nio-blocks/simulator/teams","hooks_url":"https://api.github.com/repos/nio-blocks/simulator/hooks","issue_events_url":"https://api.github.com/repos/nio-blocks/simulator/issues/events{/number}","events_url":"https://api.github.com/repos/nio-blocks/simulator/events","assignees_url":"https://api.github.com/repos/nio-blocks/simulator/assignees{/user}","branches_url":"https://api.github.com/repos/nio-blocks/simulator/branches{/branch}","tags_url":"https://api.github.com/repos/nio-blocks/simulator/tags","blobs_url":"https://api.github.com/repos/nio-blocks/simulator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nio-blocks/simulator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nio-blocks/simulator/git/refs{/sha}","trees_url":"https://api.github.com/repos/nio-blocks/simulator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nio-blocks/simulator/statuses/{sha}","languages_url":"https://api.github.com/repos/nio-blocks/simulator/languages","stargazers_url":"https://api.github.com/repos/nio-blocks/simulator/stargazers","contributors_url":"https://api.github.com/repos/nio-blocks/simulator/contributors","subscribers_url":"https://api.github.com/repos/nio-blocks/simulator/subscribers","subscription_url":"https://api.github.com/repos/nio-blocks/simulator/subscription","commits_url":"https://api.github.com/repos/nio-blocks/simulator/commits{/sha}","git_commits_url":"https://api.github.com/repos/nio-blocks/simulator/git/commits{/sha}","comments_url":"https://api.github.com/repos/nio-blocks/simulator/comments{/number}","issue_comment_url":"https://api.github.com/repos/nio-blocks/simulator/issues/comments{/number}","contents_url":"https://api.github.com/repos/nio-blocks/simulator/contents/{+path}","compare_url":"https://api.github.com/repos/nio-blocks/simulator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nio-blocks/simulator/merges","archive_url":"https://api.github.com/repos/nio-blocks/simulator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nio-blocks/simulator/downloads","issues_url":"https://api.github.com/repos/nio-blocks/simulator/issues{/number}","pulls_url":"https://api.github.com/repos/nio-blocks/simulator/pulls{/number}","milestones_url":"https://api.github.com/repos/nio-blocks/simulator/milestones{/number}","notifications_url":"https://api.github.com/repos/nio-blocks/simulator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nio-blocks/simulator/labels{/name}","releases_url":"https://api.github.com/repos/nio-blocks/simulator/releases{/id}","created_at":"2014-12-02T01:55:26Z","updated_at":"2015-04-07T23:22:00Z","pushed_at":"2015-04-08T14:03:46Z","git_url":"git://github.com/nio-blocks/simulator.git","ssh_url":"git@github.com:nio-blocks/simulator.git","clone_url":"https://github.com/nio-blocks/simulator.git","svn_url":"https://github.com/nio-blocks/simulator","homepage":"","size":300,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nio-blocks/simulator/pulls/12"},"html":{"href":"https://github.com/nio-blocks/simulator/pull/12"},"issue":{"href":"https://api.github.com/repos/nio-blocks/simulator/issues/12"},"comments":{"href":"https://api.github.com/repos/nio-blocks/simulator/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/nio-blocks/simulator/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/nio-blocks/simulator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nio-blocks/simulator/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/nio-blocks/simulator/statuses/e97f9a0939df11a9d77e140d88a08fd2db1e14e6"}}}}