Skip to content

Conversation

@ayush4874
Copy link
Contributor

@ayush4874 ayush4874 commented Dec 10, 2025

Description

This PR implements the codegen.synapse_connect_target preference discussed in #1729.

This preference allows users to override the code generation target specifically for synaptic connection statements. This is particularly useful for interactive development (e.g., on Windows with MSVC), where the overhead of compiling C++ code for simple connections is significant (~20s) compared to the Numpy implementation (<1s).

Implementation

  • Added synapse_connect_target to brian2/codegen/_prefs.py (defaults to None).
  • Updated Synapses._add_synapses_generator and Synapses._add_synapses_from_arrays to use this preference as a fallback in create_runner_codeobj.

@mstimberg mstimberg force-pushed the feature/synapse-connect-target branch from 405faae to ee7649d Compare January 5, 2026 14:55
@mstimberg
Copy link
Member

Hi @ayush4874. Many thanks for the PR, everything looks good to me. I fixed code formatting a bit, which otherwise makes our test suite fail (see the documentation for how to set up things locally: https://brian2.readthedocs.io/en/stable/developer/guidelines/style.html#code-style). Recent changes in master also touched synapses.py, and I had two add two lines that were removed when merging things. Unfortunately I messed up the git history a bit while doing these things, so I ended up force-pushing to your branch, sorry about that…

I am going to merge when/if all the tests run through successfully.

@ayush4874
Copy link
Contributor Author

Thanks @mstimberg! I really appreciate you jumping in to fix the formatting and that merge conflict.

I'll make sure to set up the pre-commit hooks locally so I catch those style issues on my end next time. No worries at all about the force push, glad it's sorted!

@mstimberg mstimberg merged commit 9620f53 into brian-team:master Jan 6, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants