All of lore.kernel.org
 help / color / mirror / Atom feed
* [master][PATCH 0/3] Fixes for PyPy
@ 2016-04-30 19:43 Christopher Larson
  2016-04-30 19:43 ` [master][PATCH 1/3] bb.build: handle __builtins__ as a module Christopher Larson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christopher Larson @ 2016-04-30 19:43 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

These reduce the dependence upon CPython, allowing bitbake to run under PyPy.
There doesn't seem to be much performance improvement, but still likely
worthwhile.


Please review the following changes for suitability for inclusion. If you have
any objections or suggestions for improvement, please respond to the patches. If
you agree with the changes, please provide your Acked-by.

The following changes since commit 309f5907a3661821e041ed14645b5d165007b058:

  bitbake: Switch to post release version (2016-04-29 07:41:34 +0100)

are available in the git repository at:

  https://github.com/kergoth/bitbake pypy-fixup
  https://github.com/kergoth/bitbake/tree/pypy-fixup

Christopher Larson (3):
  bb.build: handle __builtins__ as a module
  bb.event: handle __builtins__ as a module
  bb.data_smart: use iter() for __len__

 lib/bb/build.py      |  9 +++++++--
 lib/bb/data_smart.py |  2 +-
 lib/bb/event.py      | 11 ++++++++---
 3 files changed, 16 insertions(+), 6 deletions(-)

-- 
2.8.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [master][PATCH 1/3] bb.build: handle __builtins__ as a module
  2016-04-30 19:43 [master][PATCH 0/3] Fixes for PyPy Christopher Larson
@ 2016-04-30 19:43 ` Christopher Larson
  2016-04-30 19:43 ` [master][PATCH 2/3] bb.event: " Christopher Larson
  2016-04-30 19:43 ` [master][PATCH 3/3] bb.data_smart: use iter() for __len__ Christopher Larson
  2 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2016-04-30 19:43 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

Fixes pypy support.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 lib/bb/build.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/bb/build.py b/lib/bb/build.py
index db5072c..a5b99ed 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -61,8 +61,13 @@ def reset_cache():
 # in all namespaces, hence we add them to __builtins__.
 # If we do not do this and use the exec globals, they will
 # not be available to subfunctions.
-__builtins__['bb'] = bb
-__builtins__['os'] = os
+if hasattr(__builtins__, '__setitem__'):
+    builtins = __builtins__
+else:
+    builtins = __builtins__.__dict__
+
+builtins['bb'] = bb
+builtins['os'] = os
 
 class FuncFailed(Exception):
     def __init__(self, name = None, logfile = None):
-- 
2.8.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [master][PATCH 2/3] bb.event: handle __builtins__ as a module
  2016-04-30 19:43 [master][PATCH 0/3] Fixes for PyPy Christopher Larson
  2016-04-30 19:43 ` [master][PATCH 1/3] bb.build: handle __builtins__ as a module Christopher Larson
@ 2016-04-30 19:43 ` Christopher Larson
  2016-04-30 19:43 ` [master][PATCH 3/3] bb.data_smart: use iter() for __len__ Christopher Larson
  2 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2016-04-30 19:43 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

Fixes pypy support.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 lib/bb/event.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/bb/event.py b/lib/bb/event.py
index 5ffe89e..5a03a31 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -72,11 +72,16 @@ _catchall_handlers = {}
 _eventfilter = None
 _uiready = False
 
+if hasattr(__builtins__, '__setitem__'):
+    builtins = __builtins__
+else:
+    builtins = __builtins__.__dict__
+
 def execute_handler(name, handler, event, d):
     event.data = d
     addedd = False
-    if 'd' not in __builtins__:
-        __builtins__['d'] = d
+    if 'd' not in builtins:
+        builtins['d'] = d
         addedd = True
     try:
         ret = handler(event)
@@ -94,7 +99,7 @@ def execute_handler(name, handler, event, d):
     finally:
         del event.data
         if addedd:
-            del __builtins__['d']
+            del builtins['d']
 
 def fire_class_handlers(event, d):
     if isinstance(event, logging.LogRecord):
-- 
2.8.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [master][PATCH 3/3] bb.data_smart: use iter() for __len__
  2016-04-30 19:43 [master][PATCH 0/3] Fixes for PyPy Christopher Larson
  2016-04-30 19:43 ` [master][PATCH 1/3] bb.build: handle __builtins__ as a module Christopher Larson
  2016-04-30 19:43 ` [master][PATCH 2/3] bb.event: " Christopher Larson
@ 2016-04-30 19:43 ` Christopher Larson
  2 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2016-04-30 19:43 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

It seems the frozenset constructor in pypy runs len(), so we can't pass the
DataSmart instance directly to it, instead pass the iterator. Fixes pypy
support.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 lib/bb/data_smart.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index fa1e794..2ab884b 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -917,7 +917,7 @@ class DataSmart(MutableMapping):
              yield k
 
     def __len__(self):
-        return len(frozenset(self))
+        return len(frozenset(iter(self)))
 
     def __getitem__(self, item):
         value = self.getVar(item, False)
-- 
2.8.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-30 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-30 19:43 [master][PATCH 0/3] Fixes for PyPy Christopher Larson
2016-04-30 19:43 ` [master][PATCH 1/3] bb.build: handle __builtins__ as a module Christopher Larson
2016-04-30 19:43 ` [master][PATCH 2/3] bb.event: " Christopher Larson
2016-04-30 19:43 ` [master][PATCH 3/3] bb.data_smart: use iter() for __len__ Christopher Larson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.