# How to hide the code of the script module?

**URL:** <https://discourse.slicer.org/t/how-to-hide-the-code-of-the-script-module/26135>\
**Category:** Development\
**Tags:** python, scripted\
**Created:** [November 8, 2022, 1:20pm UTC](https://discourse.slicer.org/t/how-to-hide-the-code-of-the-script-module/26135 "2022-11-08T13:20:00Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 27, 2024, 9:27pm UTC](https://discourse.slicer.org/t/how-to-hide-the-code-of-the-script-module/26135/16 "2024-01-27T21:27:51Z")

</div>

**Background:** Support for discovering and loading scripted modules from `.pyc` files has already been implemented for all scripted plugins and modules. You can find the related changes in the [Slicer GitHub repository](https://github.com/search?q=repo%3ASlicer%2FSlicer%20.pyc&type=code).

However, it’s crucial to note that, starting with Python 3.2, the default behavior of [py\_compile.compile](https://docs.python.org/3/library/py_compile.html#py_compile.compile), which is utilized in [ctk\_compile\_python\_scripts.cmake.in](https://github.com/commontk/CTK/blob/master/CMake/ctk_compile_python_scripts.cmake.in), is to generate files like ` __pycache__ /scriptname.cpython-XY.pyc`, following the specifications in [PEP-3147](https://peps.python.org/pep-3147/). This explains why we may not have `*.pyc` files compiled after building the `CompileSlicerPythonFiles` target.

* * *

**Update** : To address this, a pull request has been submitted to the CTK repository. This pull request, available at [https://github.com/commontk/CTK/pull/1188](https://github.com/commontk/CTK/pull/1188), aims to ensure that Slicer scripts are consistently compiled as legacy `.pyc` files.

After you have a chance to test and review, we will look into integrating the corresponding changes into Slicer.

---

_[View the full topic](https://discourse.slicer.org/t/how-to-hide-the-code-of-the-script-module/26135)._
