[Bf-blender-cvs] [c0dde8be843] master: Cleanup: defer importing '_cycles' in properties.py

Campbell Barton noreply at git.blender.org
Thu Oct 15 07:53:49 CEST 2020


Commit: c0dde8be8438ebc35fe5d4498e903bdbdb34a9a8
Author: Campbell Barton
Date:   Thu Oct 15 16:25:26 2020 +1100
Branches: master
https://developer.blender.org/rBc0dde8be8438ebc35fe5d4498e903bdbdb34a9a8

Cleanup: defer importing '_cycles' in properties.py

This was imported already in nearly all usage.

Also use static-set for string comparison.

===================================================================

M	intern/cycles/blender/addon/properties.py

===================================================================

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index d29f709263e..3eeaece7c36 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -31,7 +31,6 @@ from math import pi
 
 # enums
 
-import _cycles
 from . import engine
 
 enum_devices = (
@@ -39,8 +38,10 @@ enum_devices = (
     ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in the system tab in the user preferences"),
 )
 
-if _cycles.with_network:
+from _cycles import with_network
+if with_network:
     enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),)
+del with_network
 
 enum_feature_set = (
     ('SUPPORTED', "Supported", "Only use finished and supported features"),
@@ -184,6 +185,7 @@ enum_aov_types = (
 
 
 def enum_openimagedenoise_denoiser(self, context):
+    import _cycles
     if _cycles.with_openimagedenoise:
         return [('OPENIMAGEDENOISE', "OpenImageDenoise", "Use Intel OpenImageDenoise AI denoiser running on the CPU", 4)]
     return []
@@ -1599,7 +1601,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
             elif entry.type == 'CPU':
                 cpu_devices.append(entry)
         # Extend all GPU devices with CPU.
-        if compute_device_type in ('CUDA', 'OPENCL'):
+        if compute_device_type in {'CUDA', 'OPENCL'}:
             devices.extend(cpu_devices)
         return devices



More information about the Bf-blender-cvs mailing list